Boost logo

Boost :

Subject: Re: [boost] [preprocessor] Warning: Incoming
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-07-02 05:25:02


On 07/02/2011 01:55 AM, Paul Mensonides wrote:
> On Sat, 02 Jul 2011 01:07:04 +0200, Mathias Gaunard wrote:
>
>> On 07/02/2011 12:44 AM, Paul Mensonides wrote:
>>> (I
>>> do believe, however, that std::initializer_list<T> is a misfeature. I
>>> personally think the { a, b, c } should have been mapped onto a
>>> constructor call taking a, b, and c--which may or may not use variadic
>>> templates).
>>
>> Both are possible in C++0x.
>> That's how you initialize tuples.
>
> The { a, b, c } syntax does not map onto constructors.

Yes it does.
{} has been unified to be the same as constructors in C++0x.

You can do
     tuple<int, double> t {1, 2.};
but unforunately you cannot do
     tuple<int, double> t = {1, 2.};
because tuple::tuple(int&&, double&&) is explicit (arguably a bug, it
should only be explicit in the unary case).

Both cases work with pair<int, double> (which is very important when you
want to initialize maps).

> It maps onto
> std::initializer_list<T> for some particular (and unique) T.

There are special overloading resolution rules for initializer_list that
allows the two.

But then I've already said this. If you don't want to believe me, I
invite you to take a look at the working draft for C++0x standard at
section 8.5.4.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk