rippled
ripple
beast
type_name.h
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of Beast: https://github.com/vinniefalco/Beast
4
Copyright 2014, Howard Hinnant <howard.hinnant@gmail.com>
5
6
Permission to use, copy, modify, and/or distribute this software for any
7
purpose with or without fee is hereby granted, provided that the above
8
copyright notice and this permission notice appear in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
//==============================================================================
19
20
#ifndef BEAST_TYPE_NAME_H_INCLUDED
21
#define BEAST_TYPE_NAME_H_INCLUDED
22
23
#include <
cstdlib
>
24
#include <
string
>
25
#include <
type_traits
>
26
#include <
typeinfo
>
27
28
#ifndef _MSC_VER
29
#include <cxxabi.h>
30
#endif
31
32
namespace
beast
{
33
34
template
<
typename
T>
35
std::string
36
type_name
()
37
{
38
using
TR =
typename
std::remove_reference<T>::type
;
39
40
std::string
name =
typeid
(TR).name();
41
42
#ifndef _MSC_VER
43
if
(
auto
s = abi::__cxa_demangle(name.
c_str
(),
nullptr
,
nullptr
,
nullptr
))
44
{
45
name = s;
46
std::free
(s);
47
}
48
#endif
49
50
if
(
std::is_const<TR>::value
)
51
name +=
" const"
;
52
if
(
std::is_volatile<TR>::value
)
53
name +=
" volatile"
;
54
if
(
std::is_lvalue_reference<T>::value
)
55
name +=
"&"
;
56
else
if
(
std::is_rvalue_reference<T>::value
)
57
name +=
"&&"
;
58
59
return
name;
60
}
61
62
}
// namespace beast
63
64
#endif
std::string
STL class.
std::is_lvalue_reference
std::is_rvalue_reference
std::is_volatile
std::string::c_str
T c_str(T... args)
std::remove_reference
cstdlib
std::is_const
beast::type_name
std::string type_name()
Definition:
type_name.h:36
std::free
T free(T... args)
typeinfo
type_traits
beast
Definition:
base_uint.h:641
string
Generated by
1.8.17