types/traits: add inner_type query for ::value_type
This commit is contained in:
parent
5bc2cf12d4
commit
741012151b
@ -328,4 +328,28 @@ struct is_contiguous<std::vector<T,Allocator>>: public std::true_type {};
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr auto is_contiguous_v = is_contiguous<T>::value;
|
constexpr auto is_contiguous_v = is_contiguous<T>::value;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// stores the type of '::value_type' for a given type, or the type itself if
|
||||||
|
/// it does not have such a type.
|
||||||
|
template <typename ValueT, typename = std::void_t<>>
|
||||||
|
struct inner_type {
|
||||||
|
using type = ValueT;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
template <typename ValueT>
|
||||||
|
struct inner_type<
|
||||||
|
ValueT,
|
||||||
|
std::void_t<typename ValueT::value_type>
|
||||||
|
> {
|
||||||
|
using type = typename ValueT::value_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
template <typename ValueT>
|
||||||
|
using inner_type_t = typename inner_type<ValueT>::type;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user