os/ossrv/ossrv_pub/boost_apis/boost/python/ptr.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/python/ptr.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,128 @@
     1.4 +#ifndef PTR_DWA20020601_HPP
     1.5 +# define PTR_DWA20020601_HPP
     1.6 +
     1.7 +# include <boost/python/detail/prefix.hpp>
     1.8 +// Copyright David Abrahams 2002.
     1.9 +// Distributed under the Boost Software License, Version 1.0. (See
    1.10 +// accompanying file LICENSE_1_0.txt or copy at
    1.11 +// http://www.boost.org/LICENSE_1_0.txt)
    1.12 +//
    1.13 +// Based on boost/ref.hpp, thus:
    1.14 +//  Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
    1.15 +//  Copyright (C) 2001 Peter Dimov
    1.16 +
    1.17 +# if _MSC_VER+0 >= 1020
    1.18 +#  pragma once
    1.19 +# endif
    1.20 +
    1.21 +# include <boost/config.hpp>
    1.22 +# include <boost/mpl/bool.hpp>
    1.23 +
    1.24 +namespace boost { namespace python {
    1.25 +
    1.26 +template<class Ptr> class pointer_wrapper
    1.27 +{ 
    1.28 + public:
    1.29 +    typedef Ptr type;
    1.30 +    
    1.31 +    explicit pointer_wrapper(Ptr x): p_(x) {}
    1.32 +    operator Ptr() const { return p_; }
    1.33 +    Ptr get() const { return p_; }
    1.34 + private:
    1.35 +    Ptr p_;
    1.36 +};
    1.37 +
    1.38 +template<class T>
    1.39 +inline pointer_wrapper<T> ptr(T t)
    1.40 +{ 
    1.41 +    return pointer_wrapper<T>(t);
    1.42 +}
    1.43 +
    1.44 +# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
    1.45 +template<typename T>
    1.46 +class is_pointer_wrapper
    1.47 +    : public mpl::false_
    1.48 +{
    1.49 +};
    1.50 +
    1.51 +template<typename T>
    1.52 +class is_pointer_wrapper<pointer_wrapper<T> >
    1.53 +    : public mpl::true_
    1.54 +{
    1.55 +};
    1.56 +
    1.57 +template<typename T>
    1.58 +class unwrap_pointer
    1.59 +{
    1.60 + public:
    1.61 +    typedef T type;
    1.62 +};
    1.63 +
    1.64 +template<typename T>
    1.65 +class unwrap_pointer<pointer_wrapper<T> >
    1.66 +{
    1.67 + public:
    1.68 +    typedef T type;
    1.69 +};
    1.70 +# else // no partial specialization
    1.71 +
    1.72 +}} // namespace boost::python
    1.73 +
    1.74 +#include <boost/type.hpp>
    1.75 +
    1.76 +namespace boost { namespace python {
    1.77 +
    1.78 +namespace detail
    1.79 +{
    1.80 +  typedef char (&yes_pointer_wrapper_t)[1];
    1.81 +  typedef char (&no_pointer_wrapper_t)[2];
    1.82 +      
    1.83 +  no_pointer_wrapper_t is_pointer_wrapper_test(...);
    1.84 +
    1.85 +  template<typename T>
    1.86 +  yes_pointer_wrapper_t is_pointer_wrapper_test(boost::type< pointer_wrapper<T> >);
    1.87 +
    1.88 +  template<bool wrapped>
    1.89 +  struct pointer_unwrapper
    1.90 +  {
    1.91 +      template <class T>
    1.92 +      struct apply
    1.93 +      {
    1.94 +          typedef T type;
    1.95 +      };
    1.96 +  };
    1.97 +
    1.98 +  template<>
    1.99 +  struct pointer_unwrapper<true>
   1.100 +  {
   1.101 +      template <class T>
   1.102 +      struct apply
   1.103 +      {
   1.104 +          typedef typename T::type type;
   1.105 +      };
   1.106 +  };
   1.107 +}
   1.108 +
   1.109 +template<typename T>
   1.110 +class is_pointer_wrapper
   1.111 +{
   1.112 + public:
   1.113 +    BOOST_STATIC_CONSTANT(
   1.114 +        bool, value = (
   1.115 +        sizeof(detail::is_pointer_wrapper_test(boost::type<T>()))
   1.116 +            == sizeof(detail::yes_pointer_wrapper_t)));
   1.117 +    typedef mpl::bool_<value> type;
   1.118 +};
   1.119 +
   1.120 +template <typename T>
   1.121 +class unwrap_pointer
   1.122 +    : public detail::pointer_unwrapper<
   1.123 +        is_pointer_wrapper<T>::value
   1.124 +      >::template apply<T>
   1.125 +{};
   1.126 +
   1.127 +# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
   1.128 +
   1.129 +}} // namespace boost::python
   1.130 +
   1.131 +#endif // #ifndef PTR_DWA20020601_HPP