forked from boostorg/type_index
Combine klemens-morgenstern ideas with mine. Must compile and work at least on GCC-5
This commit is contained in:
@@ -58,8 +58,6 @@ 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.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
// This cpp file:
|
||||
// * tests BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING macro
|
||||
// * outputs full ctti name so that TypeIndex library could be adjust to new compiler without requesting regression tester's help
|
||||
#define BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING (0,0,false,"")
|
||||
#define BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING (0,0,false,"",0)
|
||||
#include <boost/type_index/ctti_type_index.hpp>
|
||||
|
||||
namespace user_defined_namespace {
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
//
|
||||
// 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 <boost/config.hpp>
|
||||
#include <boost/type_index/ctti_type_index.hpp>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
#if ! defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES ) && ! defined ( BOOST_NO_CXX11_CONSTEXPR ) && ! defined( BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION )
|
||||
|
||||
template<typename ...Args>
|
||||
struct my_dummy_tuple {};
|
||||
|
||||
int main()
|
||||
{
|
||||
using ti = boost::typeindex::ctti_type_index;
|
||||
using t1 = int;
|
||||
using t2 = double;
|
||||
using t3 = my_dummy_tuple<int, double>;
|
||||
using t4 = my_dummy_tuple<double, int, int, int, double, void*>;
|
||||
|
||||
|
||||
using ct1 = typename boost::typeindex::ctti_type_index_t<t1>;
|
||||
using ct2 = typename boost::typeindex::ctti_type_index_t<t2>;
|
||||
using ct3 = typename boost::typeindex::ctti_type_index_t<t3>;
|
||||
using ct4 = typename boost::typeindex::ctti_type_index_t<t4>;
|
||||
|
||||
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<t1>().pretty_name());
|
||||
BOOST_TEST(to_string(ct2()) == ti::type_id<t2>().pretty_name());
|
||||
BOOST_TEST(to_string(ct3()) == ti::type_id<t3>().pretty_name());
|
||||
BOOST_TEST(to_string(ct4()) == ti::type_id<t4>().pretty_name());
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -74,16 +74,16 @@ void search_same() {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
#ifndef BOOST_NO_CXX14_CONSTEXPR
|
||||
template <class T>
|
||||
struct is_boost_namespace {
|
||||
constexpr char cb[5] = {'b', 'o', 'o', 's', 't'};
|
||||
constexpr boost::typeindex::ctti_type_index type = boost::typeindex::ctti_type_index::type_id<T>();
|
||||
constexpr bool value = (boost::typeindex::detail::constexpr_search(type.name(), type.name() + 5, cb, cb + 5) != cb + 5);
|
||||
static constexpr char cb[5] = {'b', 'o', 'o', 's', 't'};
|
||||
static constexpr boost::typeindex::ctti_type_index type = boost::typeindex::ctti_type_index::type_id<T>();
|
||||
static constexpr bool value = (boost::typeindex::detail::constexpr_search(type.name(), type.name() + 5, cb, cb + 5) != cb + 5);
|
||||
};
|
||||
#endif
|
||||
|
||||
*/
|
||||
|
||||
void constexpr_test() {
|
||||
using namespace boost::typeindex;
|
||||
@@ -123,11 +123,11 @@ void constexpr_test() {
|
||||
|
||||
|
||||
BOOST_CXX14_CONSTEXPR const char* int_name = t_int0.name();
|
||||
BOOST_TEST(int_name);
|
||||
BOOST_TEST(*int_name != '\0');
|
||||
|
||||
BOOST_CXX14_CONSTEXPR const char* short_name = t_short0.name();
|
||||
BOOST_TEST(short_name);
|
||||
|
||||
BOOST_TEST(*short_name != '\0');
|
||||
/*
|
||||
#ifndef BOOST_NO_CXX14_CONSTEXPR
|
||||
constexpr bool in_namespace = is_boost_namespace<ctti_type_index>::value;
|
||||
BOOST_TEST(in_namespace);
|
||||
@@ -135,7 +135,7 @@ void constexpr_test() {
|
||||
constexpr bool not_in_namespace = !is_boost_namespace<std::string>::value;
|
||||
BOOST_TEST(not_in_namespace);
|
||||
#endif
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user