メンバ関数テンプレートでC2783が出る場合
小ネタなのですが VC++(VS2017 15.5.2)で以下のコードはコンパイルに失敗します。
clangとgccでは通ります。
#include <type_traits> struct Foo { template <class U = int, class = std::enable_if_t<std::is_same_v<U,int>>> void f(); }; //template <class U, class> // <- Ok. template <class, class> // <- C2783: could not deduce template argument for '<unnamed-symbol>' void Foo::f(){} int main() { Foo f; f.f(); }
エラメッセージでは宣言を確認してください
などと書かれていますが、問題はコメントアウトしてあるテンプレートパラメータのようです。
型名までしっかり一致させないといけないので注意。