Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <map>
- #include <type_traits>
- namespace details {
- template<typename T>
- struct is_map : std::false_type { };
- template<typename Key, typename Value, typename Compare, typename Allocator>
- struct is_map<std::map<Key, Value, Compare, Allocator>> : std::true_type { };
- template<std::size_t Value>
- using constant = std::integral_constant<std::size_t, Value>;
- template<typename T, bool IsMap = is_map<T>::value>
- struct map_rank {
- using mapped_type = typename T::mapped_type;
- using mapped_type_rank = typename map_rank<mapped_type>::type;
- using type = constant<mapped_type_rank::value + 1>;
- };
- template<typename T>
- struct map_rank<T, false> {
- using type = constant<0>;
- };
- }
- template<typename Map>
- struct map_rank : details::map_rank<Map>::type { };
Add Comment
Please, Sign In to add comment