https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115285

--- Comment #16 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to frs.dumont from comment #15)
> It's surprising that we need to handle this use case. The user wants K 
> is to be explicitly built from int but then insert ints, weird.

How else would you insert a range of values constructed from the ints into the
container?

The user can insert them one-by-one like this:

for (auto i : int_range)
  m.emplace(i);

So there's no reason to prevent them from doing it using insert(first, last).

> Are other Standard library handling this ?

Yes, because the standard requires it.

The requirement on insert(i, j) is "value_type is Cpp17EmplaceConstructible
into X from *i", which means that allocator_traits<A>::construct(m, p, *i) must
be valid.

allocator_traits::construct always does explicit construction of a new object,
there is no implicit conversion.

This means that insert(i, j) must be equivalent to emplace(*i) in a loop. Which
is what my patch does.

Reply via email to