I was wondering of the following was legal according to the C++ standard:
struct Abstract { virtual ~Abstract() = 0; };
auto get_type() -> Abstract;
// I use `get_type` only to extract the return type.
using MyType = decltype(get_type());
GCC 6.3 accept it, but Clang 3.9 reject it.
However, if I do this instead:
auto get_type() -> struct Abstract;
struct Abstract { virtual ~Abstract() = 0; };
using MyType = decltype(get_type());
Now both compiler accept it. Are they both wrong in this case?
In [class.abstract], pretty straightforwardly:
An abstract class shall not be used as a parameter type, as a function return type, or as the type of an explicit conversion.
Any code that tries to do such a thing is ill-formed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With