diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 6986c96..0d44f58 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -58,6 +58,8 @@ test-suite type_index [ link-fail testing_crossmodule.cpp test_lib_nortti : : link_fail_rtti_nortti ] [ run testing_crossmodule.cpp test_lib_rtti_compat : : : $(nortti) $(compat) : testing_crossmodule_nortti_rtti_compat ] [ run testing_crossmodule.cpp test_lib_nortti_compat : : : $(compat) : testing_crossmodule_rtti_nortti_compat ] + # The constexpr meta_type + [ run test_constexpr.cpp ] ; # Assuring that examples compile and run. Adding sources from `examples` directory to the `type_index` test suite. diff --git a/test/test_constexpr.cpp b/test/test_constexpr.cpp new file mode 100644 index 0000000..1c9dd52 --- /dev/null +++ b/test/test_constexpr.cpp @@ -0,0 +1,67 @@ +// +// Copyright Klemens Morgenstern +// +// 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 +#include +#include + + +#include + +#include +using namespace std; + +#if ! defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES ) && ! defined ( BOOST_NO_CXX11_CONSTEXPR ) && ! defined( BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION ) + +template +struct my_dummy_tuple {}; + +int main() +{ + using ti = boost::typeindex::ctti_type_index; + using t1 = int; + using t2 = double; + using t3 = my_dummy_tuple; + using t4 = my_dummy_tuple; + + + using ct1 = typename boost::typeindex::ctti_type_index_t; + using ct2 = typename boost::typeindex::ctti_type_index_t; + using ct3 = typename boost::typeindex::ctti_type_index_t; + using ct4 = typename boost::typeindex::ctti_type_index_t; + + BOOST_STATIC_ASSERT( ct1() != ct2()); + BOOST_STATIC_ASSERT( ct1() == ct1()); + + BOOST_STATIC_ASSERT( ct2() < ct1()); + BOOST_STATIC_ASSERT( ct3() > ct4()); + BOOST_STATIC_ASSERT( ct1() >= ct1()); + BOOST_STATIC_ASSERT( ct1() <= ct1()); + + + cout << ct1().to_string() << endl; + cout << ct2().to_string() << endl; + cout << ct3().to_string() << endl; + cout << ct4().to_string() << endl; + + BOOST_TEST(to_string(ct1()) == ti::type_id().pretty_name()); + BOOST_TEST(to_string(ct2()) == ti::type_id().pretty_name()); + BOOST_TEST(to_string(ct3()) == ti::type_id().pretty_name()); + BOOST_TEST(to_string(ct4()) == ti::type_id().pretty_name()); + + return boost::report_errors(); +} + +#else + +int main() +{ + + + return 0; +} +#endif