Chris@16
|
1 #ifndef OTHER_DWA20020601_HPP
|
Chris@16
|
2 # define OTHER_DWA20020601_HPP
|
Chris@16
|
3
|
Chris@16
|
4 # include <boost/python/detail/prefix.hpp>
|
Chris@16
|
5 // Copyright David Abrahams 2002.
|
Chris@16
|
6 // Distributed under the Boost Software License, Version 1.0. (See
|
Chris@16
|
7 // accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
8 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
9
|
Chris@16
|
10 # if _MSC_VER+0 >= 1020
|
Chris@16
|
11 # pragma once
|
Chris@16
|
12 # endif
|
Chris@16
|
13
|
Chris@16
|
14 # include <boost/config.hpp>
|
Chris@16
|
15
|
Chris@16
|
16 namespace boost { namespace python {
|
Chris@16
|
17
|
Chris@16
|
18 template<class T> struct other
|
Chris@16
|
19 {
|
Chris@16
|
20 typedef T type;
|
Chris@16
|
21 };
|
Chris@16
|
22
|
Chris@16
|
23 # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
Chris@16
|
24 namespace detail
|
Chris@16
|
25 {
|
Chris@16
|
26 template<typename T>
|
Chris@16
|
27 class is_other
|
Chris@16
|
28 {
|
Chris@16
|
29 public:
|
Chris@16
|
30 BOOST_STATIC_CONSTANT(bool, value = false);
|
Chris@16
|
31 };
|
Chris@16
|
32
|
Chris@16
|
33 template<typename T>
|
Chris@16
|
34 class is_other<other<T> >
|
Chris@16
|
35 {
|
Chris@16
|
36 public:
|
Chris@16
|
37 BOOST_STATIC_CONSTANT(bool, value = true);
|
Chris@16
|
38 };
|
Chris@16
|
39
|
Chris@16
|
40 template<typename T>
|
Chris@16
|
41 class unwrap_other
|
Chris@16
|
42 {
|
Chris@16
|
43 public:
|
Chris@16
|
44 typedef T type;
|
Chris@16
|
45 };
|
Chris@16
|
46
|
Chris@16
|
47 template<typename T>
|
Chris@16
|
48 class unwrap_other<other<T> >
|
Chris@16
|
49 {
|
Chris@16
|
50 public:
|
Chris@16
|
51 typedef T type;
|
Chris@16
|
52 };
|
Chris@16
|
53 }
|
Chris@16
|
54 # else // no partial specialization
|
Chris@16
|
55
|
Chris@16
|
56 }} // namespace boost::python
|
Chris@16
|
57
|
Chris@16
|
58 #include <boost/type.hpp>
|
Chris@16
|
59
|
Chris@16
|
60 namespace boost { namespace python {
|
Chris@16
|
61
|
Chris@16
|
62 namespace detail
|
Chris@16
|
63 {
|
Chris@16
|
64 typedef char (&yes_other_t)[1];
|
Chris@16
|
65 typedef char (&no_other_t)[2];
|
Chris@16
|
66
|
Chris@16
|
67 no_other_t is_other_test(...);
|
Chris@16
|
68
|
Chris@16
|
69 template<typename T>
|
Chris@16
|
70 yes_other_t is_other_test(type< other<T> >);
|
Chris@16
|
71
|
Chris@16
|
72 template<bool wrapped>
|
Chris@16
|
73 struct other_unwrapper
|
Chris@16
|
74 {
|
Chris@16
|
75 template <class T>
|
Chris@16
|
76 struct apply
|
Chris@16
|
77 {
|
Chris@16
|
78 typedef T type;
|
Chris@16
|
79 };
|
Chris@16
|
80 };
|
Chris@16
|
81
|
Chris@16
|
82 template<>
|
Chris@16
|
83 struct other_unwrapper<true>
|
Chris@16
|
84 {
|
Chris@16
|
85 template <class T>
|
Chris@16
|
86 struct apply
|
Chris@16
|
87 {
|
Chris@16
|
88 typedef typename T::type type;
|
Chris@16
|
89 };
|
Chris@16
|
90 };
|
Chris@16
|
91
|
Chris@16
|
92 template<typename T>
|
Chris@16
|
93 class is_other
|
Chris@16
|
94 {
|
Chris@16
|
95 public:
|
Chris@16
|
96 BOOST_STATIC_CONSTANT(
|
Chris@16
|
97 bool, value = (
|
Chris@16
|
98 sizeof(detail::is_other_test(type<T>()))
|
Chris@16
|
99 == sizeof(detail::yes_other_t)));
|
Chris@16
|
100 };
|
Chris@16
|
101
|
Chris@16
|
102 template <typename T>
|
Chris@16
|
103 class unwrap_other
|
Chris@16
|
104 : public detail::other_unwrapper<
|
Chris@16
|
105 is_other<T>::value
|
Chris@16
|
106 >::template apply<T>
|
Chris@16
|
107 {};
|
Chris@16
|
108 }
|
Chris@16
|
109
|
Chris@16
|
110 # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
Chris@16
|
111
|
Chris@16
|
112 }} // namespace boost::python
|
Chris@16
|
113
|
Chris@16
|
114 #endif // #ifndef OTHER_DWA20020601_HPP
|