I have the following code:
Code:
#include <iostream>
using namespace std;
template<typename... Args>
void ConsoleLog(Args... args)
{
std::initializer_list<int>{ (std::cout << std::forward<Args>(args), 0)... };
}
int main()
{
ConsoleLog("foo", 1, 3.14, false, std::endl);
cout << "Hello, World!" << endl;
return 0;
}
It fails, with the message:
Code:
main.cpp:13:46: error: too many arguments to function 'void ConsoleLog(Args...) [with Args = {}]'
If I remove std::endl from the argument list, it compiles just fine.
What rule is being violated by passing std::endl in this context?
I get the same output on all versions of G++ that I've tried, including 6.1.1.