Should deduction guides insist on instantiating primary template?

15 hours ago 1
ARTICLE AD BOX

Consider the following hierarchy with base class, with primary template undefined, and defined specialization, and derived template class having a deduction guide:

#include <type_traits> template <class...> struct fn_ref_call; template <class R, class... Args> struct fn_ref_call<R (Args...)> { static constexpr bool enable = true; }; template <class... S> struct fn_ref : private fn_ref_call<S...> { private: using base = fn_ref_call<S...>; public: template<class F> requires (base::enable) fn_ref(F* f){} }; template<class F> requires std::is_function_v<F> fn_ref(F *) -> fn_ref<F>; int fn(int) { return 3; } int main() { fn_ref f{&fn}; }

This is compiled by MSVC and gcc, but not Clang: https://godbolt.org/z/Yfqhz1dW9

Clang is trying to use the undefined primary template for CTAD.

Questions:

Is clang correct here? Is there a workaround?
Read Entire Article