diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-06-25 22:59:01 +0000 |
---|---|---|
committer | <> | 2013-09-27 11:49:28 +0000 |
commit | 8c4528713d907ee2cfd3bfcbbad272c749867f84 (patch) | |
tree | c09e2ce80f47b90c85cc720f5139089ad9c8cfff /libs/python/test/indirect_traits_test.cpp | |
download | boost-tarball-baserock/morph.tar.gz |
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_54_0.tar.bz2.boost_1_54_0baserock/morph
Diffstat (limited to 'libs/python/test/indirect_traits_test.cpp')
-rw-r--r-- | libs/python/test/indirect_traits_test.cpp | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/libs/python/test/indirect_traits_test.cpp b/libs/python/test/indirect_traits_test.cpp new file mode 100644 index 000000000..594cfe555 --- /dev/null +++ b/libs/python/test/indirect_traits_test.cpp @@ -0,0 +1,117 @@ +// Copyright David Abrahams 2004. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +//#include <stdio.h> +#define BOOST_ENABLE_ASSERT_HANDLER +#include <boost/assert.hpp> +#include <boost/type_traits/is_member_function_pointer.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/python/detail/indirect_traits.hpp> +#include <boost/mpl/assert.hpp> + +//#define print(expr) printf("%s ==> %s\n", #expr, expr) + +// not all the compilers can handle an incomplete class type here. +struct X {}; + +using namespace boost::python::indirect_traits; + +typedef void (X::*pmf)(); + +BOOST_MPL_ASSERT((is_reference_to_function<int (&)()>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_function<int (*)()>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_function<int&>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_function<pmf>)); + +BOOST_MPL_ASSERT_NOT((is_pointer_to_function<int (&)()>)); +BOOST_MPL_ASSERT((is_pointer_to_function<int (*)()>)); +BOOST_MPL_ASSERT_NOT((is_pointer_to_function<int (*&)()>)); +BOOST_MPL_ASSERT_NOT((is_pointer_to_function<int (*const&)()>)); +BOOST_MPL_ASSERT_NOT((is_pointer_to_function<pmf>)); + +BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<int (&)()>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<int (*)()>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<int&>)); +BOOST_MPL_ASSERT((is_reference_to_function_pointer<int (*&)()>)); +BOOST_MPL_ASSERT((is_reference_to_function_pointer<int (*const&)()>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_function_pointer<pmf>)); + +BOOST_MPL_ASSERT((is_reference_to_pointer<int*&>)); +BOOST_MPL_ASSERT((is_reference_to_pointer<int* const&>)); +BOOST_MPL_ASSERT((is_reference_to_pointer<int*volatile&>)); +BOOST_MPL_ASSERT((is_reference_to_pointer<int*const volatile&>)); +BOOST_MPL_ASSERT((is_reference_to_pointer<int const*&>)); +BOOST_MPL_ASSERT((is_reference_to_pointer<int const* const&>)); +BOOST_MPL_ASSERT((is_reference_to_pointer<int const*volatile&>)); +BOOST_MPL_ASSERT((is_reference_to_pointer<int const*const volatile&>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<pmf>)); + +BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<int const volatile>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<int>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_pointer<int*>)); + +BOOST_MPL_ASSERT_NOT((is_reference_to_const<int*&>)); +BOOST_MPL_ASSERT((is_reference_to_const<int* const&>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_const<int*volatile&>)); +BOOST_MPL_ASSERT((is_reference_to_const<int*const volatile&>)); + +BOOST_MPL_ASSERT_NOT((is_reference_to_const<int const volatile>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_const<int>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_const<int*>)); + +BOOST_MPL_ASSERT((is_reference_to_non_const<int*&>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int* const&>)); +BOOST_MPL_ASSERT((is_reference_to_non_const<int*volatile&>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int*const volatile&>)); + +BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int const volatile>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_non_const<int*>)); + +BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int*&>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int* const&>)); +BOOST_MPL_ASSERT((is_reference_to_volatile<int*volatile&>)); +BOOST_MPL_ASSERT((is_reference_to_volatile<int*const volatile&>)); + +BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int const volatile>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int>)); +BOOST_MPL_ASSERT_NOT((is_reference_to_volatile<int*>)); + +namespace tt = boost::python::indirect_traits; + +BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<int>)); +BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<int&>)); +BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<int*>)); + + +BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<pmf>)); +BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<pmf const&>)); + +BOOST_MPL_ASSERT_NOT((tt::is_reference_to_class<X>)); + +BOOST_MPL_ASSERT((tt::is_reference_to_class<X&>)); +BOOST_MPL_ASSERT((tt::is_reference_to_class<X const&>)); +BOOST_MPL_ASSERT((tt::is_reference_to_class<X volatile&>)); +BOOST_MPL_ASSERT((tt::is_reference_to_class<X const volatile&>)); + +BOOST_MPL_ASSERT_NOT((is_pointer_to_class<int>)); +BOOST_MPL_ASSERT_NOT((is_pointer_to_class<int*>)); +BOOST_MPL_ASSERT_NOT((is_pointer_to_class<int&>)); + +BOOST_MPL_ASSERT_NOT((is_pointer_to_class<X>)); +BOOST_MPL_ASSERT_NOT((is_pointer_to_class<X&>)); +BOOST_MPL_ASSERT_NOT((is_pointer_to_class<pmf>)); +BOOST_MPL_ASSERT_NOT((is_pointer_to_class<pmf const>)); +BOOST_MPL_ASSERT((is_pointer_to_class<X*>)); +BOOST_MPL_ASSERT((is_pointer_to_class<X const*>)); +BOOST_MPL_ASSERT((is_pointer_to_class<X volatile*>)); +BOOST_MPL_ASSERT((is_pointer_to_class<X const volatile*>)); + +BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf&>)); +BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf const&>)); +BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf volatile&>)); +BOOST_MPL_ASSERT((tt::is_reference_to_member_function_pointer<pmf const volatile&>)); +BOOST_MPL_ASSERT_NOT((tt::is_reference_to_member_function_pointer<pmf[2]>)); +BOOST_MPL_ASSERT_NOT((tt::is_reference_to_member_function_pointer<pmf(&)[2]>)); +BOOST_MPL_ASSERT_NOT((tt::is_reference_to_member_function_pointer<pmf>)); + |