Better rvalue emulation support in extractors

Means that inserting rvalues into unordered_set/unordered_map won't
create a node if no insert is required.
This commit is contained in:
Daniel James
2017-05-01 21:03:11 +01:00
parent 2e14c340a8
commit 338a94e577
2 changed files with 71 additions and 11 deletions

View File

@@ -4267,6 +4267,11 @@ template <class ValueType> struct set_extractor
static key_type const& extract(value_type const& v) { return v; }
static key_type const& extract(BOOST_UNORDERED_RV_REF(value_type) v)
{
return v;
}
static no_key extract() { return no_key(); }
template <class Arg> static no_key extract(Arg const&) { return no_key(); }
@@ -4306,6 +4311,22 @@ template <class ValueType> struct map_extractor
return v.first;
}
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template <class Second>
static key_type const& extract(
boost::rv<std::pair<key_type, Second> > const& v)
{
return v.first;
}
template <class Second>
static key_type const& extract(
boost::rv<std::pair<key_type const, Second> > const& v)
{
return v.first;
}
#endif
template <class Arg1>
static key_type const& extract(key_type const& k, Arg1 const&)
{