mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-13 11:17:06 +07:00
simple name_of impl for types (gcc, clang)
This commit is contained in:
@@ -22,6 +22,46 @@ TEST_CASE("meta/meta_base/name_of") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::name_of;
|
||||
|
||||
#if META_HPP_DETAIL_COMPILER_ID == META_HPP_DETAIL_CLANG_COMPILER_ID
|
||||
CHECK(name_of<meta_tests_ns::E>() == "meta_tests_ns::E");
|
||||
|
||||
CHECK(name_of<meta_tests_ns::A>() == "meta_tests_ns::A");
|
||||
CHECK(name_of<meta_tests_ns::A[]>() == "meta_tests_ns::A[]");
|
||||
CHECK(name_of<meta_tests_ns::A*>() == "meta_tests_ns::A *");
|
||||
CHECK(name_of<meta_tests_ns::A&>() == "meta_tests_ns::A &");
|
||||
CHECK(name_of<const meta_tests_ns::A&>() == "const meta_tests_ns::A &");
|
||||
|
||||
CHECK(name_of<decltype(&meta_tests_ns::A::add)>() == "int (meta_tests_ns::A::*)(int)");
|
||||
CHECK(name_of<decltype(&meta_tests_ns::A::sub)>() == "int (*)(int)");
|
||||
CHECK(name_of<decltype(&meta_tests_ns::A::member)>() == "int meta_tests_ns::A::*");
|
||||
|
||||
CHECK(name_of<int>() == "int");
|
||||
CHECK(name_of<float>() == "float");
|
||||
|
||||
CHECK(name_of<void>() == "void");
|
||||
CHECK(name_of<const void>() == "const void");
|
||||
#endif
|
||||
|
||||
#if META_HPP_DETAIL_COMPILER_ID == META_HPP_DETAIL_GCC_COMPILER_ID
|
||||
CHECK(name_of<meta_tests_ns::E>() == "meta_tests_ns::E");
|
||||
|
||||
CHECK(name_of<meta_tests_ns::A>() == "meta_tests_ns::A");
|
||||
CHECK(name_of<meta_tests_ns::A[]>() == "meta_tests_ns::A []");
|
||||
CHECK(name_of<meta_tests_ns::A*>() == "meta_tests_ns::A*");
|
||||
CHECK(name_of<meta_tests_ns::A&>() == "meta_tests_ns::A&");
|
||||
CHECK(name_of<const meta_tests_ns::A&>() == "const meta_tests_ns::A&");
|
||||
|
||||
CHECK(name_of<decltype(&meta_tests_ns::A::add)>() == "int (meta_tests_ns::A::*)(int)");
|
||||
CHECK(name_of<decltype(&meta_tests_ns::A::sub)>() == "int (*)(int)");
|
||||
CHECK(name_of<decltype(&meta_tests_ns::A::member)>() == "int meta_tests_ns::A::*");
|
||||
|
||||
CHECK(name_of<int>() == "int");
|
||||
CHECK(name_of<float>() == "float");
|
||||
|
||||
CHECK(name_of<void>() == "void");
|
||||
CHECK(name_of<const void>() == "const void");
|
||||
#endif
|
||||
|
||||
#if META_HPP_DETAIL_COMPILER_ID == META_HPP_DETAIL_MSVC_COMPILER_ID
|
||||
CHECK(name_of<meta_tests_ns::E>() == "enum meta_tests_ns::E");
|
||||
|
||||
|
||||
@@ -16,14 +16,14 @@ namespace meta_hpp::detail
|
||||
struct name_of_wrapper_impl {};
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr std::string_view name_of_impl() noexcept {
|
||||
[[nodiscard]] constexpr auto name_of_impl() noexcept {
|
||||
#if META_HPP_DETAIL_COMPILER_ID == META_HPP_DETAIL_CLANG_COMPILER_ID
|
||||
constexpr auto prefix = std::string_view{"[T = "};
|
||||
constexpr auto suffix = std::string_view{"]"};
|
||||
constexpr auto prefix = std::string_view{"name_of_wrapper_impl<"};
|
||||
constexpr auto suffix = std::string_view{">]"};
|
||||
constexpr auto fnsign = std::string_view{__PRETTY_FUNCTION__};
|
||||
#elif META_HPP_DETAIL_COMPILER_ID == META_HPP_DETAIL_GCC_COMPILER_ID
|
||||
constexpr auto prefix = std::string_view{"with T = "};
|
||||
constexpr auto suffix = std::string_view{"]"};
|
||||
constexpr auto prefix = std::string_view{"name_of_wrapper_impl<"};
|
||||
constexpr auto suffix = std::string_view{">]"};
|
||||
constexpr auto fnsign = std::string_view{__PRETTY_FUNCTION__};
|
||||
#elif META_HPP_DETAIL_COMPILER_ID == META_HPP_DETAIL_MSVC_COMPILER_ID
|
||||
constexpr auto prefix = std::string_view{"name_of_wrapper_impl<"};
|
||||
|
||||
Reference in New Issue
Block a user