I recently stumbles across some problem with initializer lists. Consider a program that stores map-like data
struct MyMapLike {
MyMapLike(std::map
What do you think about the former and latter form of initialization? Does it make sense to be required to have extra braces in this case?
I think so. I think it would permit too much ambiguity to allow a constructor be called not just when the syntax matches that constructor, but when the syntax matches some constructor of the single argument to the constructor, and so on recursively.
struct A { int i; };
struct B { B(A) {} B(int) {} };
struct C { C(B) {} };
C c{1};
Do you consider the requirement for addition of an initializer list constructor in this case bad?
No. It lets you get the syntax you want but without creating the problems that arise if we make the compiler search harder for a constructor to use.