以下是以clang编写的,而不是用gcc编写的:
template <class... Ts, class... Args>
void f(Ts&&..., Args&&...);
int main()
{
f();
}
这就是GCC的错误:
main.cpp: In function 'int main()':
main.cpp:30:7: error: no matching function for call to 'f()'
f();
^
main.cpp:30:7: note
我正在研究一些简化的函数式编程方法,以帮助在C++中进行数据分析,我遇到了这样一种情况:我觉得我的实现应该有效,但g++不同意我的看法。请参阅下列代码:
#include <algorithm>
#include <valarray>
#include <functional>
#include <iostream>
using namespace std;
//generates a list of [from,to] in increments of step. last is <= to with precision of ste
这对C++14无效吗?
auto f = [](auto x, auto y = std::decay_t<decltype(x)>{}) { };
f(0);
我以为这大致相当于
auto f = [](int x, int y) { };
f(0, int{});
GCC 6.3和Clang 4.0都不接受我的代码。
GCC
族
这与我对C++模板演绎阶段的缺乏了解有关吗?1400页长的规范实际上对我的问题有明确的答案吗?
更新
总之,我的问题实际上可以归结为这段代码(没有lambda,单个参数),并且在C++14下是无效的(谢谢@BaummitAugen和@