type_traits: added is_transparent[_v] utility
This commit is contained in:
@@ -509,6 +509,25 @@ struct is_ebco_eligible
|
||||
template<typename Type>
|
||||
inline constexpr bool is_ebco_eligible_v = is_ebco_eligible<Type>::value;
|
||||
|
||||
/**
|
||||
* @brief Provides the member constant `value` to true if `Type::is_transparent`
|
||||
* is valid and denotes a type, false otherwise.
|
||||
* @tparam Type The type to test.
|
||||
*/
|
||||
template<typename Type, typename = void>
|
||||
struct is_transparent: std::false_type {};
|
||||
|
||||
/*! @copydoc is_transparent */
|
||||
template<typename Type>
|
||||
struct is_transparent<Type, std::void_t<typename Type::is_transparent>>: std::true_type {};
|
||||
|
||||
/**
|
||||
* @brief Helper variable template.
|
||||
* @tparam Type The type to test.
|
||||
*/
|
||||
template<typename Type>
|
||||
inline constexpr bool is_transparent_v = is_transparent<Type>::value;
|
||||
|
||||
/**
|
||||
* @cond TURN_OFF_DOXYGEN
|
||||
* Internal details not to be documented.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
@@ -160,6 +161,13 @@ TEST(TypeTraits, IsEBCOEligible) {
|
||||
static_assert(!entt::is_ebco_eligible_v<void>);
|
||||
}
|
||||
|
||||
TEST(TypeTraits, IsTransparent) {
|
||||
static_assert(!entt::is_transparent_v<std::less<int>>);
|
||||
static_assert(entt::is_transparent_v<std::less<void>>);
|
||||
static_assert(!entt::is_transparent_v<std::logical_not<double>>);
|
||||
static_assert(entt::is_transparent_v<std::logical_not<void>>);
|
||||
}
|
||||
|
||||
TEST(TypeTraits, ConstnessAs) {
|
||||
static_assert(std::is_same_v<entt::constness_as_t<int, char>, int>);
|
||||
static_assert(std::is_same_v<entt::constness_as_t<const int, char>, int>);
|
||||
|
||||
Reference in New Issue
Block a user