mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-29 19:07:15 +02:00
pair_traits for getting pair types without instantiating.
I was having some problems in an abandoned prototype with incomplete types, I'm not sure I will have this problem now, but I'm keeping this anyway, as it seems useful.
This commit is contained in:
@ -337,6 +337,23 @@ struct compressed
|
||||
compressed& operator=(compressed const&);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// pair_traits
|
||||
//
|
||||
// Used to get the types from a pair without instantiating it.
|
||||
|
||||
template <typename Pair> struct pair_traits
|
||||
{
|
||||
typedef typename Pair::first_type first_type;
|
||||
typedef typename Pair::second_type second_type;
|
||||
};
|
||||
|
||||
template <typename T1, typename T2> struct pair_traits<std::pair<T1, T2> >
|
||||
{
|
||||
typedef T1 first_type;
|
||||
typedef T2 second_type;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4512) // assignment operator could not be generated.
|
||||
@ -3186,10 +3203,11 @@ template <class ValueType> struct set_extractor
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class Key, class ValueType> struct map_extractor
|
||||
template <class ValueType> struct map_extractor
|
||||
{
|
||||
typedef ValueType value_type;
|
||||
typedef typename boost::remove_const<Key>::type key_type;
|
||||
typedef typename boost::remove_const<typename boost::unordered::detail::
|
||||
pair_traits<ValueType>::first_type>::type key_type;
|
||||
|
||||
static key_type const& extract(value_type const& v) { return v.first; }
|
||||
|
||||
|
@ -29,7 +29,7 @@ template <typename A, typename K, typename M, typename H, typename P> struct map
|
||||
typedef typename pick::link_pointer link_pointer;
|
||||
|
||||
typedef boost::unordered::detail::table_impl<types> table;
|
||||
typedef boost::unordered::detail::map_extractor<K, value_type> extractor;
|
||||
typedef boost::unordered::detail::map_extractor<value_type> extractor;
|
||||
|
||||
typedef typename boost::unordered::detail::pick_policy<K>::type policy;
|
||||
|
||||
@ -62,7 +62,7 @@ struct multimap
|
||||
typedef typename pick::link_pointer link_pointer;
|
||||
|
||||
typedef boost::unordered::detail::grouped_table_impl<types> table;
|
||||
typedef boost::unordered::detail::map_extractor<K, value_type> extractor;
|
||||
typedef boost::unordered::detail::map_extractor<value_type> extractor;
|
||||
|
||||
typedef typename boost::unordered::detail::pick_policy<K>::type policy;
|
||||
|
||||
|
Reference in New Issue
Block a user