Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:38

0001 // Copyright David Abrahams 2002.
0002 // Distributed under the Boost Software License, Version 1.0. (See
0003 // accompanying file LICENSE_1_0.txt or copy at
0004 // http://www.boost.org/LICENSE_1_0.txt)
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 // If forward declared, msvc6.5 does not recognize them as inline.
0016 // However, as of msvc14.15 (_MSC_VER 1915/Visual Studio 15.8.0) name lookup is now consistent with other compilers.
0017 // forward declaration, required (at least) by Tru64 cxx V6.5-042 and msvc14.15
0018 template <class Generator, class U>
0019 inline typename Generator::result_type
0020 unwind_type(U const& p, Generator* = 0);
0021 
0022 // forward declaration, required (at least) by Tru64 cxx V6.5-042 and msvc14.15
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 // Call this one with both template parameters explicitly specified
0145 // and no function arguments:
0146 //
0147 //      return unwind_type<my_generator,T>();
0148 //
0149 // Doesn't work if T is an array type; we could handle that case, but
0150 // why bother?
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 }}} // namespace boost::python::detail
0171 
0172 #endif // UNWIND_TYPE_DWA200222_HPP