type_traits: make is_iterator also support void *
This commit is contained in:
@@ -446,6 +446,26 @@ struct is_complete<Type, std::void_t<decltype(sizeof(Type))>>: std::true_type {}
|
||||
template<typename Type>
|
||||
inline constexpr bool is_complete_v = is_complete<Type>::value;
|
||||
|
||||
/**
|
||||
* @cond TURN_OFF_DOXYGEN
|
||||
* Internal details not to be documented.
|
||||
*/
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<typename, typename = void>
|
||||
struct is_iterator: std::false_type {};
|
||||
|
||||
template<typename Type>
|
||||
struct is_iterator<Type, std::void_t<typename std::iterator_traits<Type>::iterator_category>>: std::true_type {};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
/**
|
||||
* Internal details not to be documented.
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Provides the member constant `value` to true if a given type is an
|
||||
* iterator, false otherwise.
|
||||
@@ -456,8 +476,8 @@ struct is_iterator: std::false_type {};
|
||||
|
||||
/*! @copydoc is_iterator */
|
||||
template<typename Type>
|
||||
struct is_iterator<Type, std::void_t<typename std::iterator_traits<Type>::iterator_category>>
|
||||
: std::true_type {};
|
||||
struct is_iterator<Type, std::enable_if_t<!std::is_same_v<std::remove_const_t<std::remove_pointer_t<Type>>, void>>>
|
||||
: internal::is_iterator<Type> {};
|
||||
|
||||
/**
|
||||
* @brief Helper variable template.
|
||||
|
||||
@@ -136,6 +136,7 @@ TEST(TypeTraits, IsComplete) {
|
||||
|
||||
TEST(TypeTraits, IsIterator) {
|
||||
static_assert(!entt::is_iterator_v<void>);
|
||||
static_assert(!entt::is_iterator_v<void *>);
|
||||
static_assert(!entt::is_iterator_v<int>);
|
||||
|
||||
static_assert(entt::is_iterator_v<int *>);
|
||||
|
||||
Reference in New Issue
Block a user