File indexing completed on 2025-01-18 09:50:38
0001
0002
0003
0004
0005 #ifndef UNWIND_TYPE_DWA200222_HPP
0006 # define UNWIND_TYPE_DWA200222_HPP
0007
0008 # include <boost/python/detail/cv_category.hpp>
0009 # include <boost/python/detail/indirect_traits.hpp>
0010 # include <boost/python/detail/type_traits.hpp>
0011
0012 namespace boost { namespace python { namespace detail {
0013
0014 #if (!defined(_MSC_VER) || _MSC_VER >= 1915)
0015
0016
0017
0018 template <class Generator, class U>
0019 inline typename Generator::result_type
0020 unwind_type(U const& p, Generator* = 0);
0021
0022
0023 template <class Generator, class U>
0024 inline typename Generator::result_type
0025 unwind_type(boost::type<U>*p = 0, Generator* = 0);
0026 #endif
0027
0028 template <class Generator, class U>
0029 inline typename Generator::result_type
0030 unwind_type_cv(U* p, cv_unqualified, Generator* = 0)
0031 {
0032 return Generator::execute(p);
0033 }
0034
0035 template <class Generator, class U>
0036 inline typename Generator::result_type
0037 unwind_type_cv(U const* p, const_, Generator* = 0)
0038 {
0039 return unwind_type(const_cast<U*>(p), (Generator*)0);
0040 }
0041
0042 template <class Generator, class U>
0043 inline typename Generator::result_type
0044 unwind_type_cv(U volatile* p, volatile_, Generator* = 0)
0045 {
0046 return unwind_type(const_cast<U*>(p), (Generator*)0);
0047 }
0048
0049 template <class Generator, class U>
0050 inline typename Generator::result_type
0051 unwind_type_cv(U const volatile* p, const_volatile_, Generator* = 0)
0052 {
0053 return unwind_type(const_cast<U*>(p), (Generator*)0);
0054 }
0055
0056 template <class Generator, class U>
0057 inline typename Generator::result_type
0058 unwind_ptr_type(U* p, Generator* = 0)
0059 {
0060 typedef typename cv_category<U>::type tag;
0061 return unwind_type_cv<Generator>(p, tag());
0062 }
0063
0064 template <bool is_ptr>
0065 struct unwind_helper
0066 {
0067 template <class Generator, class U>
0068 static typename Generator::result_type
0069 execute(U p, Generator* = 0)
0070 {
0071 return unwind_ptr_type(p, (Generator*)0);
0072 }
0073 };
0074
0075 template <>
0076 struct unwind_helper<false>
0077 {
0078 template <class Generator, class U>
0079 static typename Generator::result_type
0080 execute(U& p, Generator* = 0)
0081 {
0082 return unwind_ptr_type(&p, (Generator*)0);
0083 }
0084 };
0085
0086 template <class Generator, class U>
0087 inline typename Generator::result_type
0088 #if (!defined(_MSC_VER) || _MSC_VER >= 1915)
0089 unwind_type(U const& p, Generator*)
0090 #else
0091 unwind_type(U const& p, Generator* = 0)
0092 #endif
0093 {
0094 return unwind_helper<is_pointer<U>::value>::execute(p, (Generator*)0);
0095 }
0096
0097 enum { direct_ = 0, pointer_ = 1, reference_ = 2, reference_to_pointer_ = 3 };
0098 template <int indirection> struct unwind_helper2;
0099
0100 template <>
0101 struct unwind_helper2<direct_>
0102 {
0103 template <class Generator, class U>
0104 static typename Generator::result_type
0105 execute(U(*)(), Generator* = 0)
0106 {
0107 return unwind_ptr_type((U*)0, (Generator*)0);
0108 }
0109 };
0110
0111 template <>
0112 struct unwind_helper2<pointer_>
0113 {
0114 template <class Generator, class U>
0115 static typename Generator::result_type
0116 execute(U*(*)(), Generator* = 0)
0117 {
0118 return unwind_ptr_type((U*)0, (Generator*)0);
0119 }
0120 };
0121
0122 template <>
0123 struct unwind_helper2<reference_>
0124 {
0125 template <class Generator, class U>
0126 static typename Generator::result_type
0127 execute(U&(*)(), Generator* = 0)
0128 {
0129 return unwind_ptr_type((U*)0, (Generator*)0);
0130 }
0131 };
0132
0133 template <>
0134 struct unwind_helper2<reference_to_pointer_>
0135 {
0136 template <class Generator, class U>
0137 static typename Generator::result_type
0138 execute(U&(*)(), Generator* = 0)
0139 {
0140 return unwind_ptr_type(U(0), (Generator*)0);
0141 }
0142 };
0143
0144
0145
0146
0147
0148
0149
0150
0151 template <class Generator, class U>
0152 inline typename Generator::result_type
0153 #if (!defined(_MSC_VER) || _MSC_VER >= 1915)
0154 unwind_type(boost::type<U>*, Generator*)
0155 #else
0156 unwind_type(boost::type<U>*p =0, Generator* =0)
0157 #endif
0158 {
0159 BOOST_STATIC_CONSTANT(int, indirection
0160 = (is_pointer<U>::value ? pointer_ : 0)
0161 + (indirect_traits::is_reference_to_pointer<U>::value
0162 ? reference_to_pointer_
0163 : is_lvalue_reference<U>::value
0164 ? reference_
0165 : 0));
0166
0167 return unwind_helper2<indirection>::execute((U(*)())0,(Generator*)0);
0168 }
0169
0170 }}}
0171
0172 #endif