Skip to content

Commit 8ef634b

Browse files
committed
上級者向けの解説を追加
1 parent 550c9ab commit 8ef634b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

021-cpp17-core-constexpr-lambda.md

+22
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@ int main()
4343
}
4444
~~~
4545

46+
以下の内容は上級者向けの解説であり、通常の読者は理解する必要がない。
47+
48+
constexprラムダ式はSFINAEの文脈で使うことができない。
49+
50+
~~~c++
51+
// エラー
52+
template < typename T,
53+
bool b = []{
54+
T t ;
55+
t.func() ;
56+
return true ;
57+
}() ; >
58+
void f()
59+
{
60+
T t ;
61+
t.func() ;
62+
}
63+
~~~
64+
65+
なぜならば、これを許してしまうとテンプレート仮引数に対して任意の式や文がテンプレートのSubstitutionに失敗するかどうかをチェックできてしまうからだ。
66+
67+
上級者向けの解説終わり。
4668
4769
機能テストマクロは__cpp_constexpr, 値は201603。
4870

0 commit comments

Comments
 (0)