Consider this code:
#include <type_traits>
template < typename > struct BB { };
template < > struct BB<float> : BB<int> { };
struct DD : BB<float> { };
template < typename... Args >
void ff(BB<Args...>) { }
int main()
{
ff(BB<float>{});
ff(DD{}); // FAILS! 'BB<Args ...>' is an ambiguous base class of 'DD'
return 0;
}
The call of ff(DD{})
fails to compile, as gcc-8.3
doesn't want to pick one from BB<float>
and BB<int>
(clang
does the same). But BB<float>
isa BB<int>
, so why just BB<float>
can't be picked?!
The questions are: is this according to the standard and is there a workaround while defining ff
or BB
to help gcc-8.3
to pick BB<float>
?