Skip to content

Commit 4f5907f

Browse files
committed
C++17 : 「noexcept付きのラムダ式から変換する関数ポインタにnoexceptを付加する」を追加
1 parent d5a1aa4 commit 4f5907f

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

lang/cpp17.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ C++17では以下のTSが採用された:
8787

8888
| 言語機能 | 説明 |
8989
|----------|------|
90-
| 例外仕様を型システムの一部にする | 関数の型に例外仕様が含まれるようにする |
90+
| [例外仕様を型システムの一部にする](cpp17/exception_spec_be_part_of_the_type_system.md.nolink) | 関数の型に例外仕様が含まれるようにする |
9191
| 非推奨だった古い例外仕様を削除 | `throw`キーワードによる例外仕様を削除。`throw()`は残る |
9292

9393

@@ -128,6 +128,7 @@ C++17では以下のTSが採用された:
128128
| 言語機能 | 説明 |
129129
|----------|------|
130130
| [更新された定義済みマクロ](cpp17/predefined_macros.md) | 標準規格で定義されたマクロの更新 |
131+
| [`noexcept`付きのラムダ式から変換する関数ポインタに`noexcept`を付加する](cpp17/lambda_to_noexcept_function_pointer.md) | キャプチャを持たない非ジェネリックラムダに`noexcept`を付加した場合、変換した関数ポインタに`noexcept`を付加する |
131132

132133

133134
## ライブラリ更新の概要
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# noexcept付きのラムダ式から変換する関数ポインタにnoexceptを付加する
2+
* cpp17[meta cpp]
3+
4+
## 概要
5+
キャプチャを持たない非ジェネリックなラムダ式は、関数ポインタに変換できる。そのラムダ式が例外を投げない指定をされていた場合、変換された関数ポインタもまた`noexcept`を持つ。
6+
7+
例外を投げない指定とは、以下のいずれかである:
8+
9+
- `noexcept`
10+
- `noexcept(true)`
11+
- `throw()` (C++17から非推奨)
12+
13+
14+
##
15+
```cpp
16+
#include <iostream>
17+
18+
int main()
19+
{
20+
int(*fp)() noexcept = []() noexcept { return 1; };
21+
22+
std::cout << fp() << std::endl;
23+
}
24+
```
25+
26+
### 出力
27+
```
28+
1
29+
```
30+
31+
32+
## 関連項目
33+
- [C++17 例外仕様を型システムの一部にする](exception_spec_be_part_of_the_type_system.md.nolink)
34+
- [C++11 ラムダ式](/lang/cpp11/lambda_expressions.md)
35+
- [C++14 ジェネリックラムダ](/lang/cpp14/generic_lambdas.md)
36+
37+
38+
## 参照
39+
- [CWG Issue 1722. Should lambda to function pointer conversion function be `noexcept`?](https://wg21.cmeerw.net/cwg/issue1722)
40+

0 commit comments

Comments
 (0)