1 // Copyright David Abrahams 2002.
2 // Distributed under the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 #include <boost/python/detail/wrap_python.hpp>
6 #include <boost/python/borrowed.hpp>
7 #include <boost/static_assert.hpp>
8 
9 using namespace boost::python;
10 
11 template <class T>
assert_borrowed_ptr(T const &)12 void assert_borrowed_ptr(T const&)
13 {
14     BOOST_STATIC_ASSERT(boost::python::detail::is_borrowed_ptr<T>::value);
15 }
16 
17 template <class T>
assert_not_borrowed_ptr(T const &)18 void assert_not_borrowed_ptr(T const&)
19 {
20     BOOST_STATIC_ASSERT(!boost::python::detail::is_borrowed_ptr<T>::value);
21 }
22 
main()23 int main()
24 {
25     assert_borrowed_ptr(borrowed((PyObject*)0));
26     assert_borrowed_ptr(borrowed((PyTypeObject*)0));
27     assert_borrowed_ptr((detail::borrowed<PyObject> const*)0);
28     assert_borrowed_ptr((detail::borrowed<PyObject> volatile*)0);
29     assert_borrowed_ptr((detail::borrowed<PyObject> const volatile*)0);
30     assert_not_borrowed_ptr((PyObject*)0);
31     assert_not_borrowed_ptr(0);
32     return 0;
33 }
34