Newsgroup: comp.lang.c++
Subject: could an braced-init-list be a first-class expression?
From: pietro.cerutti@...
Date: Wed, 19 Feb 2014 10:47:33 -0800 (PST)
I'm wondering what would prevent an initialization list from being a first-class expression of type std::initializer_list.
I understand that the current standar allows braced-init-lists to appear only when assigning to a scalar of type T or to an object of a class taking an std::initializer_list in the assignment operator.
Having
void f (std::vector<double> v);
It is currently possible to do this:
auto a {1, 2, 3}:
g (a);
but not to do this:
g ({1, 2, 3});
As I see it, all information the compiler needs is there. Is there any specific reason why this isn't possible?
Thanks,
Subject: could an braced-init-list be a first-class expression?
From: pietro.cerutti@...
Date: Wed, 19 Feb 2014 10:47:33 -0800 (PST)
I'm wondering what would prevent an initialization list from being a first-class expression of type std::initializer_list.
I understand that the current standar allows braced-init-lists to appear only when assigning to a scalar of type T or to an object of a class taking an std::initializer_list in the assignment operator.
Having
void f (std::vector<double> v);
It is currently possible to do this:
auto a {1, 2, 3}:
g (a);
but not to do this:
g ({1, 2, 3});
As I see it, all information the compiler needs is there. Is there any specific reason why this isn't possible?
Thanks,
via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/MC6McR
View all the progranning help forums at:
http://ift.tt/1dP9txN
No comments:
Post a Comment