This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/41933] [c++0x] lambdas and variadic templates don't work together
- From: "akim.demaille at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 21 May 2013 07:15:14 +0000
- Subject: [Bug c++/41933] [c++0x] lambdas and variadic templates don't work together
- Auto-submitted: auto-generated
- References: <bug-41933-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41933
Akim Demaille <akim.demaille at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |akim.demaille at gmail dot com
--- Comment #9 from Akim Demaille <akim.demaille at gmail dot com> ---
Hi all,
For what it's worth, Wikipedia has a note about this G++ bug:
http://en.wikipedia.org/wiki/Variadic_template . Below, a test case that
passes with clang, but fails to compile with G++ 4.9.
#include <iostream>
struct pass
{
template<typename ...T> pass(T...) {}
};
template <typename... T>
void print(T... args)
{
pass{([&]{ std::cout << args << std::endl; }(), 1)...};
}
int main()
{
print(1, "2", 3.4, '5');
}
$ g++-mp-4.9 -Wall var.cc -std=c++11
var.cc: In function 'void print(T ...)':
var.cc:11:54: error: expansion pattern '(<lambda>(), 1)' contains no argument
packs
pass{([&]{ std::cout << args << std::endl; }(), 1)...};
^
var.cc: In instantiation of 'void print(T ...) [with T = {int, const char*,
double, char}]':
var.cc:16:25: required from here
var.cc:11:4: error: no matching function for call to
'pass::pass(<brace-enclosed initializer list>)'
pass{([&]{ std::cout << args << std::endl; }(), 1)...};
^
var.cc:11:4: note: candidates are:
var.cc:5:27: note: template<class ... T> pass::pass(T ...)
template<typename ...T> pass(T...) {}
^
var.cc:5:27: note: template argument deduction/substitution failed:
var.cc:3:8: note: constexpr pass::pass(const pass&)
struct pass
^
var.cc:3:8: note: no known conversion for argument 1 from '<type error>' to
'const pass&'
var.cc:3:8: note: constexpr pass::pass(pass&&)
var.cc:3:8: note: no known conversion for argument 1 from '<type error>' to
'pass&&'