I am hoping someone can give me the technical details of why the following will not compile, and if possible, a work around.
This has been asked before, but I'm curious to see if anything has changed in newer C++ standards. Any current or future standard is acceptable.
When using a braced-init-list containing multiple braced-init-list, what are the rules defined by the standard for B, C, and D?
I am using VS2013 and this is what I'm trying to figure out:The output is:The first call to constructor #1 is fine
While reading about a different topic I came across a weird behaviour, at least to me. This whole thought originated from the special interactions between auto and braces. If you write something like:
I'd like to write a helper function like:It works well for containers:but it fails to deduce initializer_list-s (example):
Consider this snippet:Live on ColiruIf you run it, you can see that the f(int) overload was preferred, even though std::vector has an std::initializer_list constructor (see #8).
Consider this snippet:Live on ColiruIf you run it, you can see that f(int) overload was preferred, even though std::vector has a std::initializer_list constructor (see #8).
With the C++14 standard, the initialization of an std::array can go with single braces (see http://en.cppreference.com/w/cpp/container/array):
I know, that I can initialize data like this.or evenI can also do it with std::vectorLet's say I want to write my own class: