diff --git a/lang/cpp17/type_deduction_for_class_templates.md b/lang/cpp17/type_deduction_for_class_templates.md index 6f5012924..0d71bf481 100644 --- a/lang/cpp17/type_deduction_for_class_templates.md +++ b/lang/cpp17/type_deduction_for_class_templates.md @@ -203,11 +203,17 @@ int main() ### クラステンプレートの型推論を回避する例 ```cpp +// C++20 で追加された std::type_identity と同じことをするクラス +template +struct identity { + using type = T; +}; + template struct X { - using T_ = T; + using T_ = typename identity::type; - // テンプレートパラメータを直接使用せず、型の別名を付けてから使用する。 + // テンプレートパラメータを直接使用せず、identityを介して使用する。 // これによって、テンプレート引数を明示的に指定させられる X(T_) {} };