34 return abi::__cxa_demangle(
typeid(T).name(),
nullptr,
nullptr, &status);
42const string_view
type_of(
auto const & t)
noexcept {
43 return type<remove_cvref_t<
decltype(t)>>;
47template <
typename T,
typename ... candidates>
48concept one_of_t = (std::is_same_v<T,candidates> || ... ||
false);
51template <
typename T,
typename ... candidates>
56#if defined(EIN_TESTING) || defined(EIN_TESTING_TYPES)
62TEST_CASE(
"types",
"[types]") {
64 SECTION(
"provides correct demangled names") {
65 SECTION(
"Basic types") {
66 CHECK(
"int"s == type<int>);
67 CHECK(
"double"s == type<double>);
70 SECTION(
"User-defined types") {
71 CHECK(type<Custom> ==
"Custom"s);
74 SECTION(
"Pointers and References") {
75 CHECK(type<int*> ==
"int*");
76 CHECK(type<int&> ==
"int");
77 CHECK(type<int&> ==
"int");
81 SECTION(
"type_of extracts type from object") {
82 SECTION(
"Literals and basic types") {
89 SECTION(
"Constant and reference types") {
99 SECTION(
"one_of_t concept identifies types within list") {
101 SECTION(
"Valid and invalid cases") {
102 REQUIRE(one_of_t<int, int, double, float>);
103 REQUIRE_FALSE(one_of_t<char, int, double, float>);
107 SECTION(
"not_one_of_t concept identifies types outside of list") {
109 SECTION(
"Valid and invalid cases") {
110 REQUIRE(not_one_of_t<char, int, double, float>);
111 REQUIRE_FALSE(not_one_of_t<int, int, double, float>);
type T is not one of the candidates
type T is one of the candidates
#define ein_nodiscard
C++17 [[nodiscard]].
#define ein_const
[[const]] is not const
const string_view type_of(auto const &t) noexcept
returns the unmangled name of a the type of the (unused) argument passed to this function
const string_view type
returns the unmangled name of a the type T