dune-common
2.3.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
dune
common
classname.hh
Go to the documentation of this file.
1
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
// vi: set et ts=4 sw=2 sts=2:
3
#ifndef DUNE_CLASSNAME_HH
4
#define DUNE_CLASSNAME_HH
5
11
#include <cstdlib>
12
#include <string>
13
#include <typeinfo>
14
15
#if HAVE_CXA_DEMANGLE
16
#include <cxxabi.h>
17
#endif // #if HAVE_CXA_DEMANGLE
18
19
namespace
Dune {
20
22
template
<
class
T>
23
std::string
className
( T &
t
)
24
{
25
std::string
className
=
typeid
(
t
).name();
26
#if HAVE_CXA_DEMANGLE
27
int
status;
28
char
*demangled = abi::__cxa_demangle( className.c_str(), 0, 0, &status );
29
if
( demangled )
30
{
31
className = demangled;
32
std::free( demangled );
33
}
34
#endif // #if HAVE_CXA_DEMANGLE
35
return
className
;
36
}
37
39
template
<
class
T>
40
std::string
className
()
41
{
42
std::string
className
=
typeid
( T ).name();
43
#if HAVE_CXA_DEMANGLE
44
int
status;
45
char
*demangled = abi::__cxa_demangle( className.c_str(), 0, 0, &status );
46
if
( demangled )
47
{
48
className = demangled;
49
std::free( demangled );
50
}
51
#endif // #if HAVE_CXA_DEMANGLE
52
return
className
;
53
}
54
55
}
// namespace Dune
56
57
#endif // DUNE_CLASSNAME_HH
Generated on Mon Feb 10 2014 23:52:37 for dune-common by
1.8.1.2