add check type
This commit is contained in:
parent
c0239a52e5
commit
b68625ca7a
1 changed files with 11 additions and 3 deletions
|
@ -143,6 +143,14 @@ template <typename E, typename U = std::underlying_type_t<E>>
|
|||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct check final {
|
||||
using type = void;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using check_t = typename check<T>::type;
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] constexpr std::string_view nameof_impl(std::string_view name, bool with_template_suffix) noexcept {
|
||||
if (name.length() >= 1 && (name.front() == '"' || name.front() == '\'')) {
|
||||
|
@ -245,13 +253,13 @@ template <typename T>
|
|||
} // namespace nameof
|
||||
|
||||
// NAMEOF obtains simple (unqualified) string name of variable, function, enum, macro.
|
||||
#define NAMEOF(...) ::nameof::detail::nameof_impl<decltype(__VA_ARGS__)>(#__VA_ARGS__, false)
|
||||
#define NAMEOF(...) ::nameof::detail::nameof_impl<::nameof::detail::check_t<decltype(__VA_ARGS__)>>(#__VA_ARGS__, false)
|
||||
|
||||
// Obtains simple (unqualified) full (with template suffix) string name of variable, function, enum, macro.
|
||||
#define NAMEOF_FULL(...) ::nameof::detail::nameof_impl<decltype(__VA_ARGS__)>(#__VA_ARGS__, true)
|
||||
#define NAMEOF_FULL(...) ::nameof::detail::nameof_impl<::nameof::detail::check_t<decltype(__VA_ARGS__)>>(#__VA_ARGS__, true)
|
||||
|
||||
// Obtains raw string name of variable, function, enum, macro.
|
||||
#define NAMEOF_RAW(...) ::nameof::detail::nameof_raw_impl<decltype(__VA_ARGS__)>(#__VA_ARGS__)
|
||||
#define NAMEOF_RAW(...) ::nameof::detail::nameof_raw_impl<::nameof::detail::check_t<decltype(__VA_ARGS__)>>(#__VA_ARGS__)
|
||||
|
||||
// Obtains simple (unqualified) string enum name of enum variable.
|
||||
#define NAMEOF_ENUM(...) ::nameof::nameof_enum<decltype(__VA_ARGS__)>(__VA_ARGS__)
|
||||
|
|
Loading…
Reference in a new issue