1//
2// Trivial test for core::demangle
3//
4// Copyright (c) 2014 Peter Dimov
5// Copyright (c) 2014 Andrey Semashev
6//
7// Distributed under the Boost Software License, Version 1.0.
8// See accompanying file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt
10//
11
12#include <boost/core/demangle.hpp>
13#include <typeinfo>
14#include <iostream>
15
16template<class T1, class T2> struct Y1
17{
18};
19
20void test_demangle()
21{
22 typedef Y1<int, long> T;
23 std::cout << boost::core::demangle( name: typeid( T ).name() ) << std::endl;
24}
25
26void test_demangle_alloc()
27{
28 typedef Y1<int, long> T;
29 const char* p = boost::core::demangle_alloc( name: typeid( T ).name() );
30 if (p)
31 {
32 std::cout << p << std::endl;
33 boost::core::demangle_free(name: p);
34 }
35 else
36 {
37 std::cout << "[demangling failed]" << std::endl;
38 }
39}
40
41void test_scoped_demangled_name()
42{
43 typedef Y1<int, long> T;
44 boost::core::scoped_demangled_name demangled_name( typeid( T ).name() );
45 const char* p = demangled_name.get();
46 if (p)
47 {
48 std::cout << p << std::endl;
49 }
50 else
51 {
52 std::cout << "[demangling failed]" << std::endl;
53 }
54}
55
56int main()
57{
58 test_demangle();
59 test_demangle_alloc();
60 test_scoped_demangled_name();
61 return 0;
62}
63

source code of boost/libs/core/test/demangle_test.cpp