yohhoyの日記

技術的メモをしていきたい日記

2020-08-20から1日間の記事一覧

decltype(auto) as non-type template-parameter

C++

非型テンプレートのプレースホルダ型にはautoまたはdecltype(auto)いずれも利用できる。素直にautoを使うべき。本記事の内容はStackOverflowで見つけた質問と回答に基づく。 template <auto N> struct S { /*...*/ }; // または template <decltype(auto) N> struct S { /*...*/ }; S<4</decltype(auto)></auto>…