This code used to compile in Clang 3.8, and still compiles in VS 2017, but started emitting an error in Clang 3.9.
template <typename D, typename ... I>
struct impl : I ...
{};
template <typename D, typename ... I>
void f(impl<D, I...> const&)
{}
struct A : impl<A> {};
struct B : impl<B, A> {};
int main()
{
f(A());
f(B()); // Error
}
Clang 3.9 says
<source>:15:5: error: no matching function for call to 'f'
f(B());
^
<source>:6:6: note: candidate template ignored: failed template argument deduction
void f(impl<D, I...> const&)
^
All three compilers in action: http://ift.tt/2qpQwjl
I want f(A()) to deduce D = A, I... = <> and f(B()) to deduce D = B, I... = A, which is then deducible as an instance of impl. My end goal is to detect type in impl's parameter pack that are themselves instances of impl. Am I going about this the wrong way?
Aucun commentaire:
Enregistrer un commentaire