Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Pairs

Since the containers use std::pair they're limited to the version from the current standard library. But since C++11 std::pair's piecewise_construct based constructor is very useful, emplace emulates it with a piecewise_construct in the boost::unordered namespace. So for example, the following will work:

boost::unordered_multimap<std::string, std::complex> x;

x.emplace(
    boost::unordered::piecewise_construct,
    boost::make_tuple("key"), boost::make_tuple(1, 2));

Older drafts of the standard also supported variadic constructors for std::pair, where the first argument would be used for the first part of the pair, and the remaining for the second part.


PrevUpHomeNext