diff --git a/include/boost/python/detail/borrowed_ptr.hpp b/include/boost/python/detail/borrowed_ptr.hpp index 055c8b7c..527dfc46 100755 --- a/include/boost/python/detail/borrowed_ptr.hpp +++ b/include/boost/python/detail/borrowed_ptr.hpp @@ -7,7 +7,10 @@ // to its suitability for any purpose. # include -#include +# include +# include +# include +# include namespace boost { namespace python { namespace detail { @@ -23,6 +26,7 @@ struct is_borrowed_ptr BOOST_STATIC_CONSTANT(bool, value = false); }; +# if !defined(__MWERKS__) || __MWERKS__ > 0x3000 template struct is_borrowed_ptr*> { @@ -46,16 +50,41 @@ struct is_borrowed_ptr const volatile*> { BOOST_STATIC_CONSTANT(bool, value = true); }; +# else +template +struct is_borrowed +{ + BOOST_STATIC_CONSTANT(bool, value = false); +}; +template +struct is_borrowed > +{ + BOOST_STATIC_CONSTANT(bool, value = true); +}; +template +struct is_borrowed_ptr + : is_borrowed::type> +{ +}; +# endif # else // no partial specialization typedef char (&yes_borrowed_ptr_t)[1]; typedef char (&no_borrowed_ptr_t)[2]; - + no_borrowed_ptr_t is_borrowed_ptr_test(...); +template +typename mpl::select_type< + is_pointer::value + , T + , int + >::type +is_borrowed_ptr_test1(boost::type); + template -yes_borrowed_ptr_t is_borrowed_ptr_test(boost::type< borrowed* >); +yes_borrowed_ptr_t is_borrowed_ptr_test(borrowed const volatile*); template class is_borrowed_ptr @@ -63,7 +92,7 @@ class is_borrowed_ptr public: BOOST_STATIC_CONSTANT( bool, value = ( - sizeof(detail::is_borrowed_ptr_test(boost::type())) + sizeof(detail::is_borrowed_ptr_test(is_borrowed_ptr_test1(boost::type()))) == sizeof(detail::yes_borrowed_ptr_t))); }; diff --git a/test/borrowed.cpp b/test/borrowed.cpp index b46dafb0..0f8d3112 100755 --- a/test/borrowed.cpp +++ b/test/borrowed.cpp @@ -3,6 +3,7 @@ // copyright notice appears in all copies. This software is provided // "as is" without express or implied warranty, and with no claim as // to its suitability for any purpose. +#include #include #include