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

--- Comment #16 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #14)
> > Jonathan, has anyone suggested adding generic init_list constructors to the
> > container classes?
> 
> Not that I'm aware of. There might be concerns about introducing more
> ambiguities like the vector<int>{1,2} case.

Yes, I had to constrain it to when there is a conversion from __elt to
value_type.  Might as well also require value_type to be a class.

> > What do you think about doing the above translation in the compiler?  Is the
> > compiler allowed to do that?
> 
> Good question.
> 
> If the compiler first checked that the code as-written would call the
> initializer_list<value_type> constructor (and not some other constructor)
> then it should be safe to do it.

My current hack checks for a list of at least 8 elements to exclude other
constructors, but checking actual overload resolution does sound safer.

Reply via email to