• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 template<class T1, class T2> struct Y1
17 {
18 };
19 
test_demangle()20 void test_demangle()
21 {
22     typedef Y1<int, long> T;
23     std::cout << boost::core::demangle( typeid( T ).name() ) << std::endl;
24 }
25 
test_demangle_alloc()26 void test_demangle_alloc()
27 {
28     typedef Y1<int, long> T;
29     const char* p = boost::core::demangle_alloc( typeid( T ).name() );
30     if (p)
31     {
32         std::cout << p << std::endl;
33         boost::core::demangle_free(p);
34     }
35     else
36     {
37         std::cout << "[demangling failed]" << std::endl;
38     }
39 }
40 
test_scoped_demangled_name()41 void 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 
main()56 int main()
57 {
58     test_demangle();
59     test_demangle_alloc();
60     test_scoped_demangled_name();
61     return 0;
62 }
63