Out of interest I played with this
As an important datapoint, I knew that std::map
(in C++11) supports piecewise construction of it's value pairs:
std::map<int, A> stdMap;
stdMap.emplace(std::piecewise_construct,
std::forward_as_tuple(1),
std::forward_as_tuple());
would therefore invoke the contructor you're after. However, somehow, the same doesn't immediately work for Boost's map
. Hmmm.
However, this piqued my interest: boost uses std::pair<const K, V>
as the value type?!
boost::container::map<int, A>::value_type p {
std::piecewise_construct,
std::forward_as_tuple(1),
std::forward_as_tuple(true)
};
works no problem. And I can also verify that this typedef is in fact the type stored:
static_assert(std::is_same<decltype(p), std::remove_reference<decltype(*myMap.begin())>::type>::value, "Nonstandard pair");
So, it's beginning to look like a bug in the forwarding via the interal tree implementation when it uses the allocator::construct
call.