repr 0.1
Reconstructable string representations and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
ctti.h
Go to the documentation of this file.
#pragma once
#include <cstddef>
#include <string>
#include <string_view>
namespace librepr::
#if USING(REPR_CTTI)
#endif
ctti {
namespace librepr::detail {
template <typename T>
constexpr auto get_ctti() {
#if USING(LIBREPR_COMPILER_MSVC)
constexpr auto prefix = std::string_view{"get_ctti<"};
constexpr auto suffix = std::string_view{">(void)"};
#else
constexpr auto prefix = std::string_view{"T = "};
constexpr auto suffix = std::string_view{"]"};
#endif
constexpr std::size_t start = signature.find(prefix) + prefix.size();
constexpr std::size_t end = signature.find(suffix, start);
constexpr auto value = signature.substr(start, end - start);
return const_string<value.size()>(value);
}
template <typename T>
constexpr inline auto raw_type_name = get_ctti<T>();
} // namespace librepr::detail
template <typename T>
constexpr inline auto type_name = std::string_view{librepr::detail::raw_type_name<T>};
template <typename T>
} // namespace librepr::inline ctti