Skip to content

Commit 108258e

Browse files
committed
✨ Expose types in type_pair
Problem: - Iterating a `type_map` is fine using `template_for_each` but it's difficult to extract the first and second (or key and value) types. Solution: - Add `first_type` and `second_type` to `type_pair`. - Add `key_type` and `value_type` to `type_pair`.
1 parent 5b5da86 commit 108258e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

include/stdx/utility.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ template <auto V> struct value_t {
3131
};
3232
} // namespace detail
3333

34-
template <typename K, typename V> struct type_pair {};
34+
template <typename K, typename V> struct type_pair {
35+
using first_type = K;
36+
using second_type = V;
37+
using key_type = K;
38+
using value_type = V;
39+
};
3540
template <typename K, typename V> using tt_pair = type_pair<K, V>;
3641
template <auto K, typename V> using vt_pair = tt_pair<detail::value_t<K>, V>;
3742
template <typename K, auto V> using tv_pair = tt_pair<K, detail::value_t<V>>;

0 commit comments

Comments
 (0)