Yes, this method ensures that implicit conversions are not allowed. However, this also means that this property does not arise from the definition only void func(string). So, to make this clear to readers, you could make it more self-sufficient as follows:
template <typename T, typename U> using RequireExplicit = enable_if_t<is_same<T, U>>;
template <typename T, typename = RequireExplicit<T, string>>
void func(T){}
source
share