types/traits: check for begin/end in is_container_v

This commit is contained in:
Danny Robson 2018-12-17 12:40:44 +11:00
parent 5144dd137a
commit 15de10c19d

View File

@ -294,9 +294,18 @@ using nth_argument_t = typename nth_argument<N, FuncT>::type;
///////////////////////////////////////////////////////////////////////////////
/// A trait that tests if a type `T` is a container type.
///
/// That is, a type that has:
/// * container typedefs such as value_type, reference, iterator, etc.
/// * viable std::begin/std::end overloads
///
/// Defaults to false.
template <typename T, typename = std::void_t<>>
struct is_container : public std::false_type {};
///----------------------------------------------------------------------------
template <typename T>
struct is_container<
T,
@ -307,15 +316,14 @@ struct is_container<
typename T::iterator,
typename T::const_iterator,
typename T::difference_type,
typename T::size_type
typename T::size_type,
decltype(std::end (std::declval<T> ())),
decltype(std::begin (std::declval<T> ()))
>
> : public std::true_type {};
template <size_t N, typename ValueT>
struct is_container<std::array<ValueT,N>> : public std::true_type {};
//-----------------------------------------------------------------------------
template <typename T>
constexpr auto is_container_v = is_container<T>::value;