mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-16 14:09:02 +07:00
revert all about debug names
now isn't the time for it
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
- type conversions
|
||||
- fix all includes to work with the library more flexible
|
||||
- test and support shared libraries
|
||||
- add debug type names
|
||||
|
||||
## Version 1.0
|
||||
|
||||
|
||||
@@ -1016,49 +1016,6 @@ namespace std
|
||||
};
|
||||
}
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
template < typename T >
|
||||
struct name_of_wrapper_impl {};
|
||||
|
||||
template < typename T >
|
||||
[[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{"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{"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<"};
|
||||
constexpr auto suffix = std::string_view{">>(void)"};
|
||||
constexpr auto fnsign = std::string_view{__FUNCSIG__};
|
||||
#else
|
||||
constexpr auto prefix = std::string_view{"<"};
|
||||
constexpr auto suffix = std::string_view{">"};
|
||||
constexpr auto fnsign = std::string_view{"<unknown>"};
|
||||
#endif
|
||||
constexpr auto b = fnsign.find(prefix) + prefix.size();
|
||||
constexpr auto e = fnsign.rfind(suffix);
|
||||
static_assert(b < e);
|
||||
|
||||
auto n = fnsign.substr(b, e - b);
|
||||
n.remove_prefix(std::min(n.find_first_not_of(' '), n.size()));
|
||||
n.remove_suffix(std::min(n.size() - n.find_last_not_of(' ') - 1, n.size()));
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr std::string_view name_of() noexcept {
|
||||
return impl::name_of_impl<impl::name_of_wrapper_impl<T>>();
|
||||
}
|
||||
}
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
class noncopyable {
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/meta.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include <meta.hpp/meta_all.hpp>
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
namespace meta_tests_ns
|
||||
{
|
||||
struct A {
|
||||
int member{42};
|
||||
int add(int) {return 42;}
|
||||
static int sub(int) { return 42;}
|
||||
};
|
||||
|
||||
enum class E {};
|
||||
}
|
||||
|
||||
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 || 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[]" || name_of<meta_tests_ns::A[]>() == "meta_tests_ns::A []"));
|
||||
CHECK((name_of<meta_tests_ns::A*>() == "meta_tests_ns::A*" || name_of<meta_tests_ns::A*>() == "meta_tests_ns::A *"));
|
||||
CHECK((name_of<meta_tests_ns::A&>() == "meta_tests_ns::A&" || name_of<meta_tests_ns::A&>() == "meta_tests_ns::A &"));
|
||||
CHECK((name_of<const meta_tests_ns::A&>() == "const meta_tests_ns::A&" || 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");
|
||||
|
||||
CHECK(name_of<meta_tests_ns::A>() == "struct meta_tests_ns::A");
|
||||
CHECK(name_of<meta_tests_ns::A[]>() == "struct meta_tests_ns::A [0]");
|
||||
CHECK(name_of<meta_tests_ns::A*>() == "struct meta_tests_ns::A *");
|
||||
CHECK(name_of<meta_tests_ns::A&>() == "struct meta_tests_ns::A &");
|
||||
CHECK(name_of<const meta_tests_ns::A&>() == "struct meta_tests_ns::A const &");
|
||||
|
||||
CHECK(name_of<decltype(&meta_tests_ns::A::add)>() == "int (__cdecl meta_tests_ns::A::*)(int)");
|
||||
CHECK(name_of<decltype(&meta_tests_ns::A::sub)>() == "int (__cdecl*)(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>() == "void const");
|
||||
#endif
|
||||
}
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "meta_base/insert_or_assign.hpp"
|
||||
#include "meta_base/is_in_place_type.hpp"
|
||||
#include "meta_base/memory_buffer.hpp"
|
||||
#include "meta_base/name_of.hpp"
|
||||
#include "meta_base/noncopyable.hpp"
|
||||
#include "meta_base/nonesuch.hpp"
|
||||
#include "meta_base/overloaded.hpp"
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/meta.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base.hpp"
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
template < typename T >
|
||||
struct name_of_wrapper_impl {};
|
||||
|
||||
template < typename T >
|
||||
[[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{"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{"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<"};
|
||||
constexpr auto suffix = std::string_view{">>(void)"};
|
||||
constexpr auto fnsign = std::string_view{__FUNCSIG__};
|
||||
#else
|
||||
constexpr auto prefix = std::string_view{"<"};
|
||||
constexpr auto suffix = std::string_view{">"};
|
||||
constexpr auto fnsign = std::string_view{"<unknown>"};
|
||||
#endif
|
||||
constexpr auto b = fnsign.find(prefix) + prefix.size();
|
||||
constexpr auto e = fnsign.rfind(suffix);
|
||||
static_assert(b < e);
|
||||
|
||||
auto n = fnsign.substr(b, e - b);
|
||||
n.remove_prefix(std::min(n.find_first_not_of(' '), n.size()));
|
||||
n.remove_suffix(std::min(n.size() - n.find_last_not_of(' ') - 1, n.size()));
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr std::string_view name_of() noexcept {
|
||||
return impl::name_of_impl<impl::name_of_wrapper_impl<T>>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user