1 #ifndef PTR_DWA20020601_HPP
2 # define PTR_DWA20020601_HPP
4 # include <boost/python/detail/prefix.hpp>
5 // Copyright David Abrahams 2002.
6 // Distributed under the Boost Software License, Version 1.0. (See
7 // accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
10 // Based on boost/ref.hpp, thus:
11 // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
12 // Copyright (C) 2001 Peter Dimov
14 # if _MSC_VER+0 >= 1020
18 # include <boost/config.hpp>
19 # include <boost/mpl/bool.hpp>
21 namespace boost
{ namespace python
{
23 template<class Ptr
> class pointer_wrapper
28 explicit pointer_wrapper(Ptr x
): p_(x
) {}
29 operator Ptr() const { return p_
; }
30 Ptr
get() const { return p_
; }
36 inline pointer_wrapper
<T
> ptr(T t
)
38 return pointer_wrapper
<T
>(t
);
41 # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
43 class is_pointer_wrapper
49 class is_pointer_wrapper
<pointer_wrapper
<T
> >
62 class unwrap_pointer
<pointer_wrapper
<T
> >
67 # else // no partial specialization
69 }} // namespace boost::python
71 #include <boost/type.hpp>
73 namespace boost
{ namespace python
{
77 typedef char (&yes_pointer_wrapper_t
)[1];
78 typedef char (&no_pointer_wrapper_t
)[2];
80 no_pointer_wrapper_t
is_pointer_wrapper_test(...);
83 yes_pointer_wrapper_t
is_pointer_wrapper_test(boost::type
< pointer_wrapper
<T
> >);
85 template<bool wrapped
>
86 struct pointer_unwrapper
96 struct pointer_unwrapper
<true>
101 typedef typename
T::type type
;
107 class is_pointer_wrapper
110 BOOST_STATIC_CONSTANT(
112 sizeof(detail::is_pointer_wrapper_test(boost::type
<T
>()))
113 == sizeof(detail::yes_pointer_wrapper_t
)));
114 typedef mpl::bool_
<value
> type
;
117 template <typename T
>
119 : public detail::pointer_unwrapper
<
120 is_pointer_wrapper
<T
>::value
124 # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
126 }} // namespace boost::python
128 #endif // #ifndef PTR_DWA20020601_HPP