Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef BORROWED_PTR_DWA20020601_HPP
0002 # define BORROWED_PTR_DWA20020601_HPP
0003 // Copyright David Abrahams 2002.
0004 // Distributed under the Boost Software License, Version 1.0. (See
0005 // accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 # include <boost/config.hpp>
0009 # include <boost/type.hpp>
0010 # include <boost/mpl/if.hpp>
0011 # include <boost/python/detail/type_traits.hpp>
0012 # include <boost/python/tag.hpp>
0013 
0014 namespace boost { namespace python { namespace detail {
0015 
0016 template<class T> class borrowed
0017 { 
0018     typedef T type;
0019 };
0020 
0021 template<typename T>
0022 struct is_borrowed_ptr
0023 {
0024     BOOST_STATIC_CONSTANT(bool, value = false); 
0025 };
0026 
0027 #  if !defined(__MWERKS__) || __MWERKS__ > 0x3000
0028 template<typename T>
0029 struct is_borrowed_ptr<borrowed<T>*>
0030 {
0031     BOOST_STATIC_CONSTANT(bool, value = true);
0032 };
0033 
0034 template<typename T>
0035 struct is_borrowed_ptr<borrowed<T> const*>
0036 {
0037     BOOST_STATIC_CONSTANT(bool, value = true);
0038 };
0039 
0040 template<typename T>
0041 struct is_borrowed_ptr<borrowed<T> volatile*>
0042 {
0043     BOOST_STATIC_CONSTANT(bool, value = true);
0044 };
0045 
0046 template<typename T>
0047 struct is_borrowed_ptr<borrowed<T> const volatile*>
0048 {
0049     BOOST_STATIC_CONSTANT(bool, value = true);
0050 };
0051 #  else
0052 template<typename T>
0053 struct is_borrowed
0054 {
0055     BOOST_STATIC_CONSTANT(bool, value = false);
0056 };
0057 template<typename T>
0058 struct is_borrowed<borrowed<T> >
0059 {
0060     BOOST_STATIC_CONSTANT(bool, value = true);
0061 };
0062 template<typename T>
0063 struct is_borrowed_ptr<T*>
0064     : is_borrowed<typename remove_cv<T>::type>
0065 {
0066 };
0067 #  endif 
0068 
0069 
0070 }
0071 
0072 template <class T>
0073 inline T* get_managed_object(detail::borrowed<T> const volatile* p, tag_t)
0074 {
0075     return (T*)p;
0076 }
0077 
0078 }} // namespace boost::python::detail
0079 
0080 #endif // #ifndef BORROWED_PTR_DWA20020601_HPP