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>
10
11namespace librepr::
12#if USING(REPR_CTTI)
13 inline
14#endif
15 ctti {
16namespace librepr::detail {
17template <typename T>
18constexpr 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
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
35template <typename T>
36constexpr inline auto raw_type_name = get_ctti<T>();
37
38} // namespace librepr::detail
39
40template <typename T>
41constexpr inline auto type_name = std::string_view{librepr::detail::raw_type_name<T>};
42
43template <typename T>
47} // namespace librepr::inline ctti
constexpr auto get_ctti()
Definition ctti.h:18
constexpr auto raw_type_name
Definition ctti.h:36
constexpr auto type_name
Definition ctti.h:41
std::string get_name_raw()
Definition ctti.h:44
Definition assert.h:89
Definition ctvi/ctvi.h:9
std::string code_for()
Definition repr:39
#define LIBREPR_FUNCTION_NAME
Definition platform.h:80
Definition const_string.h:9