Topic: Pack expansion across lambdas?
Author: "Johannes Schaub (litb)" <schaub-johannes@web.de>
Date: Sun, 9 May 2010 14:13:47 CST Raw View
Hello all. Is the following valid C++0x?
void g(...) { }
template<typename ...T>
void f(T...) {
g([] {
std::cout << sizeof(T) << std::endl;
return 0;
}()...
);
}
The lambda appears in an initializer-list, so i thought it's a valid context
for pack-expansion, but GCC4.5 complains with
"error: parameter packs not expanded with '...'"
Any Standard paragraph forbidding that?
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: Paul Bibbings <paul.bibbings@gmail.com>
Date: Mon, 10 May 2010 14:02:22 CST Raw View
"Johannes Schaub (litb)" <schaub-johannes@web.de> writes:
> Hello all. Is the following valid C++0x?
>
> void g(...) { }
>
> template<typename ...T>
> void f(T...) {
> g([] {
> std::cout << sizeof(T) << std::endl;
> return 0;
> }()...
> );
> }
>
> The lambda appears in an initializer-list, so i thought it's a valid
context
> for pack-expansion, but GCC4.5 complains with
>
> "error: parameter packs not expanded with '...'"
>
> Any Standard paragraph forbidding that?
>
> --
> [ comp.std.c++ is moderated. To submit articles, try just posting with ]
> [ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu<std-c%2B%2B@netlab.cs.rpi.edu>
]
> [ --- Please see the FAQ before posting. --- ]
> [ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
This does not answer your question specifically but, as I far as I am
aware, GCC still has an incomplete implementation of variadics, with
4.5.0 exhibiting continuing issues along the lines of those discussed at
http://stackoverflow.com/questions/1989552/gcc-error-with-variadic-templates-sorry-unimplemented-cannot-expand-identif
,
a thread to which, I notice, you yourself contributed. I might have
expected the error message to have been different if it was a related
issue, but it could present a complication affecting what might otherwise
be expected to work.
Regards
Paul Bibbings
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use
mailto:std-c++@netlab.cs.rpi.edu<std-c%2B%2B@netlab.cs.rpi.edu>
]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: Dragan Milenkovic <dragan@plusplus.rs>
Date: Mon, 10 May 2010 14:04:52 CST Raw View
Johannes Schaub (litb) wrote:
> Hello all. Is the following valid C++0x?
>
> void g(...) { }
>
> template<typename ...T>
> void f(T...) {
> g([] {
> std::cout << sizeof(T) << std::endl;
> return 0;
> }()...
> );
> }
>
I'm not considering whether it is correct by the Standard, or if it
is what you wanted, but moving "..." right after sizeof will produce
compilable code.
std::cout << sizeof...(T) << std::endl;
--
Dragan
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use
mailto:std-c++@netlab.cs.rpi.edu<std-c%2B%2B@netlab.cs.rpi.edu>
]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]