Boost logo

Boost Users :

Subject: Re: [Boost-users] [review][assign] Formal review of Assign v2 ongoing
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2011-06-23 22:17:19


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




Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net