jeudi 2 février 2017

Is having a function header that return an abstract type legal?

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?

Aucun commentaire:

Enregistrer un commentaire