...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Front Page / Sequences / Intrinsic Metafunctions / key_type |
Returns the key that would be used to identify X in Sequence.
#include <boost/mpl/key_type.hpp>
Parameter | Requirement | Description |
---|---|---|
Sequence | Associative Sequence | A sequence to query. |
X | Any type | The type to get the key for. |
For any Associative Sequence s, iterators pos1 and pos2 in s, and an artibrary type x:
typedef key_type<s,x>::type k;
Return type: | A type. |
---|---|
Precondition: | x can be put in s. |
Semantics: | k is the key that would be used to identify x in s. |
Postcondition: | If key_type< s,deref<pos1>::type >::type is identical to key_type< s,deref<pos2>::type >::type then pos1 is identical to pos2. |
Amortized constant time.
typedef key_type< map<>,pair<int,unsigned> >::type k1; typedef key_type< set<>,pair<int,unsigned> >::type k2; BOOST_MPL_ASSERT(( is_same< k1,int > )); BOOST_MPL_ASSERT(( is_same< k2,pair<int,unsigned> > ));