c++ 11 lambda函数中的异常规范
Exception specification in C++11 lambda Functions
对于命名函数,可以指定可能抛出的异常,如
所示void func(void) throw (string);
如何在c++ lambda函数中指定异常?
也一样。[expr.prim]中lambda的相关语法。λ):
lambda表达式:
lambda-declaratoropt复合语句lambda-introducer :
,,,,[
lambda-captureopt]
lambda-declarator :
,,,,(
参数声明子句)
mutable
opt
exception-specificationoptattribute- specific -seqopt尾随返回类型optopt
可以在参数之后提供可选的异常规范。例如:
auto never_throws = []() noexcept {
return 5;
};
int i = never_throws(); // won't throw
相关文章:
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- 处理多个异常集合的C++方法
- 我在c++代码中生成了一个运行时#3异常
- 孤立代码块在结构中引发异常
- C++中的赋值发生,尽管右侧出现异常
- 可组合的lambda/std::函数与std::可选
- C++Boost Asio Pool线程,带有lambda函数和传递引用变量
- 从构造函数抛出异常时如何克服内存泄漏
- 异常属于C++中的线程还是进程
- 当类定义不可见时捕获异常
- 如何建立使用模板函数的lambda函数的尾部返回类型
- 引发异常:读取访问冲突**dynamicArray**为0x1118235.发生
- 如何将lambda作为模板类的成员函数参数
- C++从其他 constexpr 创建 lambda 不能按顺序执行 Constexpr
- 为什么异常不退出程序?
- 在 lambda 捕获中声明的变量的类型推导
- 当使用lambda进行变量的复杂初始化时,如何处理从内部抛出的lambda外部异常
- 从 lambda 表达式中抛出异常,坏习惯
- c++ 11 lambda函数中的异常规范
- 使用lambda定义散列函数会引发异常