annotate DEPENDENCIES/generic/include/boost/python/detail/borrowed_ptr.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 #ifndef BORROWED_PTR_DWA20020601_HPP
Chris@16 2 # define BORROWED_PTR_DWA20020601_HPP
Chris@16 3 // Copyright David Abrahams 2002.
Chris@16 4 // Distributed under the Boost Software License, Version 1.0. (See
Chris@16 5 // accompanying file LICENSE_1_0.txt or copy at
Chris@16 6 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 7
Chris@16 8 # include <boost/config.hpp>
Chris@16 9 # include <boost/type.hpp>
Chris@16 10 # include <boost/mpl/if.hpp>
Chris@16 11 # include <boost/type_traits/object_traits.hpp>
Chris@16 12 # include <boost/type_traits/cv_traits.hpp>
Chris@16 13 # include <boost/python/tag.hpp>
Chris@16 14
Chris@16 15 namespace boost { namespace python { namespace detail {
Chris@16 16
Chris@16 17 template<class T> class borrowed
Chris@16 18 {
Chris@16 19 typedef T type;
Chris@16 20 };
Chris@16 21
Chris@16 22 # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Chris@16 23 template<typename T>
Chris@16 24 struct is_borrowed_ptr
Chris@16 25 {
Chris@16 26 BOOST_STATIC_CONSTANT(bool, value = false);
Chris@16 27 };
Chris@16 28
Chris@16 29 # if !defined(__MWERKS__) || __MWERKS__ > 0x3000
Chris@16 30 template<typename T>
Chris@16 31 struct is_borrowed_ptr<borrowed<T>*>
Chris@16 32 {
Chris@16 33 BOOST_STATIC_CONSTANT(bool, value = true);
Chris@16 34 };
Chris@16 35
Chris@16 36 template<typename T>
Chris@16 37 struct is_borrowed_ptr<borrowed<T> const*>
Chris@16 38 {
Chris@16 39 BOOST_STATIC_CONSTANT(bool, value = true);
Chris@16 40 };
Chris@16 41
Chris@16 42 template<typename T>
Chris@16 43 struct is_borrowed_ptr<borrowed<T> volatile*>
Chris@16 44 {
Chris@16 45 BOOST_STATIC_CONSTANT(bool, value = true);
Chris@16 46 };
Chris@16 47
Chris@16 48 template<typename T>
Chris@16 49 struct is_borrowed_ptr<borrowed<T> const volatile*>
Chris@16 50 {
Chris@16 51 BOOST_STATIC_CONSTANT(bool, value = true);
Chris@16 52 };
Chris@16 53 # else
Chris@16 54 template<typename T>
Chris@16 55 struct is_borrowed
Chris@16 56 {
Chris@16 57 BOOST_STATIC_CONSTANT(bool, value = false);
Chris@16 58 };
Chris@16 59 template<typename T>
Chris@16 60 struct is_borrowed<borrowed<T> >
Chris@16 61 {
Chris@16 62 BOOST_STATIC_CONSTANT(bool, value = true);
Chris@16 63 };
Chris@16 64 template<typename T>
Chris@16 65 struct is_borrowed_ptr<T*>
Chris@16 66 : is_borrowed<typename remove_cv<T>::type>
Chris@16 67 {
Chris@16 68 };
Chris@16 69 # endif
Chris@16 70
Chris@16 71 # else // no partial specialization
Chris@16 72
Chris@16 73 typedef char (&yes_borrowed_ptr_t)[1];
Chris@16 74 typedef char (&no_borrowed_ptr_t)[2];
Chris@16 75
Chris@16 76 no_borrowed_ptr_t is_borrowed_ptr_test(...);
Chris@16 77
Chris@16 78 template <class T>
Chris@16 79 typename mpl::if_c<
Chris@16 80 is_pointer<T>::value
Chris@16 81 , T
Chris@16 82 , int
Chris@16 83 >::type
Chris@16 84 is_borrowed_ptr_test1(boost::type<T>);
Chris@16 85
Chris@16 86 template<typename T>
Chris@16 87 yes_borrowed_ptr_t is_borrowed_ptr_test(borrowed<T> const volatile*);
Chris@16 88
Chris@16 89 template<typename T>
Chris@16 90 class is_borrowed_ptr
Chris@16 91 {
Chris@16 92 public:
Chris@16 93 BOOST_STATIC_CONSTANT(
Chris@16 94 bool, value = (
Chris@16 95 sizeof(detail::is_borrowed_ptr_test(is_borrowed_ptr_test1(boost::type<T>())))
Chris@16 96 == sizeof(detail::yes_borrowed_ptr_t)));
Chris@16 97 };
Chris@16 98
Chris@16 99 # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Chris@16 100
Chris@16 101 }
Chris@16 102
Chris@16 103 template <class T>
Chris@16 104 inline T* get_managed_object(detail::borrowed<T> const volatile* p, tag_t)
Chris@16 105 {
Chris@16 106 return (T*)p;
Chris@16 107 }
Chris@16 108
Chris@16 109 }} // namespace boost::python::detail
Chris@16 110
Chris@16 111 #endif // #ifndef BORROWED_PTR_DWA20020601_HPP