为什么下面的CTAD尝试无法编译?
template <typename T> struct C { C(T,T) {} };
template <> struct C<int> { C(int) {} };
C c(1); //error: template argument deduction failure我原以为构造函数C(int)会被推导出来。
发布于 2022-01-15 08:36:29
隐式演绎指南只为主模板中的构造函数生成,而不是为专门化的构造函数生成。
您需要显式地添加扣减指南:
C(int) -> C<int>;https://stackoverflow.com/questions/70719688
复制相似问题