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