repr
0.1
Reconstructable string representations and more
Loading...
Searching...
No Matches
ctti.h
Go to the documentation of this file.
1
#pragma once
2
#include <
cstddef
>
3
#include <
string
>
4
#include <
string_view
>
5
6
#include <
librepr/feature.h
>
7
#include <
librepr/macro/platform.h
>
8
#include <
librepr/macro/default.h
>
9
#include <
librepr/util/string/const_string.h
>
10
11
namespace
librepr
::
12
#if USING(REPR_CTTI)
13
inline
14
#endif
15
ctti
{
16
namespace
librepr::detail
{
17
template
<
typename
T>
18
constexpr
auto
get_ctti
() {
19
#if USING(LIBREPR_COMPILER_MSVC)
20
constexpr
auto
prefix =
std::string_view
{
"get_ctti<"
};
21
constexpr
auto
suffix =
std::string_view
{
">(void)"
};
22
#else
23
constexpr
auto
prefix =
std::string_view
{
"T = "
};
24
constexpr
auto
suffix =
std::string_view
{
"]"
};
25
#endif
26
27
constexpr
auto
signature
=
std::string_view
{
LIBREPR_FUNCTION_NAME
};
28
constexpr
std::size_t
start =
signature
.find(prefix) + prefix.size();
29
constexpr
std::size_t
end =
signature
.find(suffix, start);
30
31
constexpr
auto
value =
signature
.substr(start, end - start);
32
return
const_string
<value.size()>(value);
33
}
34
35
template
<
typename
T>
36
constexpr
inline
auto
raw_type_name
=
get_ctti<T>
();
37
38
}
// namespace librepr::detail
39
40
template
<
typename
T>
41
constexpr
inline
auto
type_name
=
std::string_view
{librepr::detail::raw_type_name<T>};
42
43
template
<
typename
T>
44
std::string
get_name_raw
() {
45
return
std::string
{
type_name<T>
};
46
}
47
}
// namespace librepr::inline ctti
std::string
std::string_view
const_string.h
cstddef
default.h
feature.h
librepr:: ctti::librepr::detail::get_ctti
constexpr auto get_ctti()
Definition
ctti.h:18
librepr:: ctti::librepr::detail::raw_type_name
constexpr auto raw_type_name
Definition
ctti.h:36
librepr:: ctti::type_name
constexpr auto type_name
Definition
ctti.h:41
librepr:: ctti::get_name_raw
std::string get_name_raw()
Definition
ctti.h:44
librepr::detail
Definition
assert.h:89
librepr
Definition
ctvi/ctvi.h:9
librepr::code_for
std::string code_for()
Definition
repr:39
platform.h
LIBREPR_FUNCTION_NAME
#define LIBREPR_FUNCTION_NAME
Definition
platform.h:80
std::size_t
string
string_view
librepr::const_string
Definition
const_string.h:9
include
librepr
name
ctti.h
Generated by
1.9.8, using the excellent
Doxygen Awesome
Theme