Boost logo

Boost Users :

Subject: Re: [Boost-users] [review][assign] Formal review of Assign v2 ongoing
From: John Bytheway (jbytheway+boost_at_[hidden])
Date: 2011-07-02 05:06:39


On 24/06/11 03:17, Steven Watanabe wrote:
> 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 },
> };

That doesn't work in gcc 4.5 either; I get the same error about use of
an explicit constructor.

John


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