iterator: add index_type trait

This commit is contained in:
Danny Robson 2018-06-27 17:56:19 +10:00
parent 279af4c796
commit 4094a96160

View File

@ -229,6 +229,24 @@ namespace util {
}
///////////////////////////////////////////////////////////////////////////
/// a trait that stores a type suitable for indexing a container
template <typename, typename = std::void_t<>>
struct index_type { using type = std::size_t; };
//-------------------------------------------------------------------------
template <typename ContainerT>
struct index_type<
ContainerT,
std::void_t<
typename ContainerT::index_t
>
> {
using type = typename ContainerT::index_t;
};
///////////////////////////////////////////////////////////////////////////
template <typename ContainerT>
class indices {