Chris@16: #ifndef PTR_DWA20020601_HPP Chris@16: # define PTR_DWA20020601_HPP Chris@16: Chris@16: # include Chris@16: // Copyright David Abrahams 2002. Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // Based on boost/ref.hpp, thus: Chris@16: // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) Chris@16: // Copyright (C) 2001 Peter Dimov Chris@16: Chris@16: # if _MSC_VER+0 >= 1020 Chris@16: # pragma once Chris@16: # endif Chris@16: Chris@16: # include Chris@16: # include Chris@16: Chris@16: namespace boost { namespace python { Chris@16: Chris@16: template class pointer_wrapper Chris@16: { Chris@16: public: Chris@16: typedef Ptr type; Chris@16: Chris@16: explicit pointer_wrapper(Ptr x): p_(x) {} Chris@16: operator Ptr() const { return p_; } Chris@16: Ptr get() const { return p_; } Chris@16: private: Chris@16: Ptr p_; Chris@16: }; Chris@16: Chris@16: template Chris@16: inline pointer_wrapper ptr(T t) Chris@16: { Chris@16: return pointer_wrapper(t); Chris@16: } Chris@16: Chris@16: # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION Chris@16: template Chris@16: class is_pointer_wrapper Chris@16: : public mpl::false_ Chris@16: { Chris@16: }; Chris@16: Chris@16: template Chris@16: class is_pointer_wrapper > Chris@16: : public mpl::true_ Chris@16: { Chris@16: }; Chris@16: Chris@16: template Chris@16: class unwrap_pointer Chris@16: { Chris@16: public: Chris@16: typedef T type; Chris@16: }; Chris@16: Chris@16: template Chris@16: class unwrap_pointer > Chris@16: { Chris@16: public: Chris@16: typedef T type; Chris@16: }; Chris@16: # else // no partial specialization Chris@16: Chris@16: }} // namespace boost::python Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { namespace python { Chris@16: Chris@16: namespace detail Chris@16: { Chris@16: typedef char (&yes_pointer_wrapper_t)[1]; Chris@16: typedef char (&no_pointer_wrapper_t)[2]; Chris@16: Chris@16: no_pointer_wrapper_t is_pointer_wrapper_test(...); Chris@16: Chris@16: template Chris@16: yes_pointer_wrapper_t is_pointer_wrapper_test(boost::type< pointer_wrapper >); Chris@16: Chris@16: template Chris@16: struct pointer_unwrapper Chris@16: { Chris@16: template Chris@16: struct apply Chris@16: { Chris@16: typedef T type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct pointer_unwrapper Chris@16: { Chris@16: template Chris@16: struct apply Chris@16: { Chris@16: typedef typename T::type type; Chris@16: }; Chris@16: }; Chris@16: } Chris@16: Chris@16: template Chris@16: class is_pointer_wrapper Chris@16: { Chris@16: public: Chris@16: BOOST_STATIC_CONSTANT( Chris@16: bool, value = ( Chris@16: sizeof(detail::is_pointer_wrapper_test(boost::type())) Chris@16: == sizeof(detail::yes_pointer_wrapper_t))); Chris@16: typedef mpl::bool_ type; Chris@16: }; Chris@16: Chris@16: template Chris@16: class unwrap_pointer Chris@16: : public detail::pointer_unwrapper< Chris@16: is_pointer_wrapper::value Chris@16: >::template apply Chris@16: {}; Chris@16: Chris@16: # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION Chris@16: Chris@16: }} // namespace boost::python Chris@16: Chris@16: #endif // #ifndef PTR_DWA20020601_HPP