Аргумент шаблона шаблона не может быть выведен как для foo
, так и для foo2
.
Если я удалю часть sfinae, аргумент шаблона шаблона будет успешно выведен для foo
и foo2
.
Как исправить класс span
или foo
и foo2
?
Спасибо.
Тест (также на godbolt.org )
#include <type_traits>
template<typename T>
using enable_if_t_const = typename std::enable_if<
std::is_const<T>::value
>::type;
template<typename T, typename=void> class span;
template<typename T>
class span<T, enable_if_t_const<T>> {
public:
explicit span(const T* const data) {}
};
template <typename T, template<typename> class S>
void foo() {}
template <typename T, template<typename> class S>
void foo2(S<T>& s) {}
int main() {
int arr[] = {1};
span<const int> s(arr);
foo<const int, span>();
foo2(s);
return 0;
}