forked from boostorg/core
Lift core::detail::demange to core, move demangled_name to typeinfo.hpp.
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
#ifndef BOOST_CORE_DEMANGLED_NAME_HPP_INCLUDED
|
#ifndef BOOST_CORE_DEMANGLE_HPP_INCLUDED
|
||||||
#define BOOST_CORE_DEMANGLED_NAME_HPP_INCLUDED
|
#define BOOST_CORE_DEMANGLE_HPP_INCLUDED
|
||||||
|
|
||||||
// MS compatible compilers support #pragma once
|
// MS compatible compilers support #pragma once
|
||||||
|
|
||||||
@ -7,7 +7,7 @@
|
|||||||
# pragma once
|
# pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// core::demangled_name( BOOST_CORE_TYPEID(T) )
|
// core::demangle
|
||||||
//
|
//
|
||||||
// Copyright 2014 Peter Dimov
|
// Copyright 2014 Peter Dimov
|
||||||
//
|
//
|
||||||
@ -16,7 +16,6 @@
|
|||||||
// http://www.boost.org/LICENSE_1_0.txt
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/core/typeinfo.hpp>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#if defined(__GLIBCXX__) || defined(__GLIBCPP__)
|
#if defined(__GLIBCXX__) || defined(__GLIBCPP__)
|
||||||
@ -32,9 +31,6 @@ namespace boost
|
|||||||
namespace core
|
namespace core
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
|
|
||||||
#if defined( BOOST_CORE_HAS_CXXABI_H )
|
#if defined( BOOST_CORE_HAS_CXXABI_H )
|
||||||
|
|
||||||
// lifted from boost/exception/detail/type_info.hpp
|
// lifted from boost/exception/detail/type_info.hpp
|
||||||
@ -79,25 +75,10 @@ inline std::string demangle( char const * name )
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
inline std::string demangled_name( core::typeinfo const & ti )
|
|
||||||
{
|
|
||||||
#if defined( BOOST_NO_TYPEID )
|
|
||||||
|
|
||||||
return ti.name();
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
return core::detail::demangle( ti.name() );
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace core
|
} // namespace core
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#undef BOOST_CORE_HAS_CXXABI_H
|
#undef BOOST_CORE_HAS_CXXABI_H
|
||||||
|
|
||||||
#endif // #ifndef BOOST_CORE_DEMANGLED_NAME_HPP_INCLUDED
|
#endif // #ifndef BOOST_CORE_DEMANGLE_HPP_INCLUDED
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/core/typeinfo.hpp>
|
#include <boost/core/typeinfo.hpp>
|
||||||
#include <boost/core/demangled_name.hpp>
|
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
@ -64,6 +64,11 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline char const * demangled_name( core::typeinfo const & ti )
|
||||||
|
{
|
||||||
|
return ti.name();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace core
|
} // namespace core
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
@ -111,6 +116,7 @@ template<class T> struct core_typeid_< T const volatile >: core_typeid_< T >
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#include <boost/core/demangle.hpp>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
@ -129,6 +135,11 @@ typedef std::type_info typeinfo;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
inline std::string demangled_name( core::typeinfo const & ti )
|
||||||
|
{
|
||||||
|
return core::demangle( ti.name() );
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace core
|
} // namespace core
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
@ -59,7 +59,9 @@ run-fail lightweight_test_fail4.cpp ;
|
|||||||
run-fail lightweight_test_fail5.cpp ;
|
run-fail lightweight_test_fail5.cpp ;
|
||||||
run-fail lightweight_test_fail6.cpp ;
|
run-fail lightweight_test_fail6.cpp ;
|
||||||
run-fail lightweight_test_fail7.cpp ;
|
run-fail lightweight_test_fail7.cpp ;
|
||||||
|
run-fail lightweight_test_fail7.cpp : : : <rtti>off : lightweight_test_fail7_no_rtti ;
|
||||||
run-fail lightweight_test_fail8.cpp ;
|
run-fail lightweight_test_fail8.cpp ;
|
||||||
|
run-fail lightweight_test_fail8.cpp : : : <rtti>off : lightweight_test_fail8_no_rtti ;
|
||||||
|
|
||||||
run is_same_test.cpp ;
|
run is_same_test.cpp ;
|
||||||
|
|
||||||
@ -69,4 +71,7 @@ run typeinfo_test.cpp : : : <rtti>off : typeinfo_test_no_rtti ;
|
|||||||
run iterator_test.cpp ;
|
run iterator_test.cpp ;
|
||||||
run detail_iterator_test.cpp ;
|
run detail_iterator_test.cpp ;
|
||||||
|
|
||||||
|
run demangle_test.cpp : : : <test-info>always_show_run_output ;
|
||||||
|
|
||||||
run demangled_name_test.cpp : : : <test-info>always_show_run_output ;
|
run demangled_name_test.cpp : : : <test-info>always_show_run_output ;
|
||||||
|
run demangled_name_test.cpp : : : <rtti>off <test-info>always_show_run_output : demangled_name_test_no_rtti ;
|
||||||
|
23
test/demangle_test.cpp
Normal file
23
test/demangle_test.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
//
|
||||||
|
// Trivial test for core::demangle
|
||||||
|
//
|
||||||
|
// Copyright (c) 2014 Peter Dimov
|
||||||
|
//
|
||||||
|
// 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/core/demangle.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
template<class T1, class T2> struct Y1
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
typedef Y1<int, long> T;
|
||||||
|
std::cout << boost::core::demangle( typeid( T ).name() );
|
||||||
|
return 0;
|
||||||
|
}
|
@ -8,7 +8,6 @@
|
|||||||
// http://www.boost.org/LICENSE_1_0.txt
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <boost/core/demangled_name.hpp>
|
|
||||||
#include <boost/core/typeinfo.hpp>
|
#include <boost/core/typeinfo.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user