AMDG On 06/23/2011 03:45 PM, John Bytheway wrote:
On 21/06/11 23:05, Simonson, Lucanus J wrote:
v_ v1 = { { "a", 1 }, { "b", 2 }, { "c", 3 }, { "d", 4 }, { "e", 5 } };
Arguably the extra {} around each vector element in the new initializer syntax is more readable than the proposed assign v2 syntax. Tuple and deque support initializer list as do all classes with constructors and structs.
For what it's worth, your particular example doesn't work in gcc 4.5 because the relevant constructor of std::tuple's is explicit (I wasn't aware of this effect of marking a constructor explicit, and I'm quite surprised...). The analogous example with std::pair works fine.
Yep. You have to use v_ v1{ { "a", 1 }, { "b", 2 }, { "c", 3 }, { "d", 4 }, { "e", 5 }, }; In Christ, Steven Watanabe