]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/python/test/select_holder.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / python / test / select_holder.cpp
CommitLineData
7c673cae
FG
1// Copyright David Abrahams 2002.
2// Distributed under the Boost Software License, Version 1.0. (See
3// accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5#include <boost/python/object/class_metadata.hpp>
6#include <boost/python/has_back_reference.hpp>
7#include <boost/python/detail/not_specified.hpp>
8#include <boost/static_assert.hpp>
b32b8144 9#include <boost/python/detail/type_traits.hpp>
7c673cae
FG
10#include <boost/function/function0.hpp>
11#include <boost/mpl/bool.hpp>
12#include <memory>
13
14struct BR {};
15
16struct Base {};
17struct Derived : Base {};
18
19namespace boost { namespace python
20{
21 // specialization
22 template <>
23 struct has_back_reference<BR>
24 : mpl::true_
25 {
26 };
27}} // namespace boost::python
28
29template <class T, class U>
30void assert_same(U* = 0, T* = 0)
31{
b32b8144 32 BOOST_STATIC_ASSERT((boost::python::detail::is_same<T,U>::value));
7c673cae
FG
33
34}
35
36template <class T, class Held, class Holder>
37void assert_holder(T* = 0, Held* = 0, Holder* = 0)
38{
39 using namespace boost::python::detail;
40 using namespace boost::python::objects;
41
42 typedef typename class_metadata<
43 T,Held,not_specified,not_specified
44 >::holder h;
45
46 assert_same<Holder>(
47 (h*)0
48 );
49}
50
51int test_main(int, char * [])
52{
53 using namespace boost::python::detail;
54 using namespace boost::python::objects;
55
56 assert_holder<Base,not_specified,value_holder<Base> >();
57
58 assert_holder<BR,not_specified,value_holder_back_reference<BR,BR> >();
59 assert_holder<Base,Base,value_holder_back_reference<Base,Base> >();
60 assert_holder<BR,BR,value_holder_back_reference<BR,BR> >();
61
62 assert_holder<Base,Derived
63 ,value_holder_back_reference<Base,Derived> >();
64
65 assert_holder<Base,std::auto_ptr<Base>
66 ,pointer_holder<std::auto_ptr<Base>,Base> >();
67
68 assert_holder<Base,std::auto_ptr<Derived>
69 ,pointer_holder_back_reference<std::auto_ptr<Derived>,Base> >();
70
71 assert_holder<BR,std::auto_ptr<BR>
72 ,pointer_holder_back_reference<std::auto_ptr<BR>,BR> > ();
73
74 return 0;
75}
76