mardi 1 décembre 2015

Definition of function specialization errors when following =delete declaration

I have a general template function that is =deleted, and a specialization for int

template <typename> void f() = delete;

template <>
void f<int>() { }

My goal is to have a function template that errors at compile-time (not link-time) when a specialization is not provided for the template arguments. f<int>() should succeed and f<double>() should error. While the above works with gcc, it fails with clang with error: redefinition of 'f'. If I remove the =delete it compiles fine, but then f<double>() doesn't fail until link time.

Is the above valid? Is the specialization of a deleted template a redefinition or should the specialization be another candidate for overload resolution.

Aucun commentaire:

Enregistrer un commentaire