Vin*_*ent 7 c++ compiler-construction lambda c++11 std-function
如何将默认函数指定为类成员的参数?
从我的代码派生的当前示例是:
#include <iostream>
#include <functional>
template<typename T> struct C
{
static T test(std::function<T(int)> f = [](int i){return i;})
{return f(42);}
};
int main(int argc, char* argv[])
{
C<int>::test(); // ERROR = internal compiler error : in tsubst_copy, at cp/pt.c:11354
C<int>::test([](int i){return i;}); // OK
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是GCC的错误吗?
用另一种语法可以避免这个问题吗?
你能在其他C++ 11编译器上尝试吗(对于那些有编译器的人来说)?
| 归档时间: |
|
| 查看次数: |
622 次 |
| 最近记录: |