是否存在GCC错误:默认std :: function
GCC bug or not : default 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;
}
是GCC的错误吗?
是否有可能通过另一种语法避免此问题?
您可以在其他C 11编译器上尝试一下(对于有一个人)?
毫无疑问,这是一个编译器错误。无论您的程序是否构成良好,编译器都在其自己的数据结构中检测到不一致。
请按照GCC错误报告说明:http://gcc.gnu.org/bugs/#report
相关文章:
- 如何创建一个CMake变量,除非显式重写,否则使用默认值
- "error: no matching function for call to"构造函数错误
- 如何使用默认参数等选择模板专业化
- 具有默认模板参数的多态类的模板推导失败
- 为什么在没有显式默认构造函数的情况下,将另一个结构封装在联合中作为成员的结构不能编译
- 调用专用模板时出错"no matching function for call to [...]"
- 当函数模板参数是具有默认参数的类模板时,函数模板参数的推导如何执行
- 初始化具有非默认构造函数的std::数组项的更好方法
- 何时提供默认参数作为模板参数
- 是默认情况下分配给char数组常量的值
- 具有默认值的引用获取函数
- 具有默认模板类型的默认构造函数的类型推导
- 库函数需要一个 std::function<void(void)>,如何传入类函数?
- Confusion: decltype vs std::function
- 使编译器为 std::function 生成一个空的默认函数
- 是否存在GCC错误:默认std :: function
- 如何创建一个 std::function 作为方法参数,并将 std::stoi 作为默认值
- 分配默认值 std::function
- 使用默认复制构造函数时出错:"deleted function"
- 我应该如何使用默认参数定义 std::function 变量