Consider some abstract class A
:
class A
{
virtual void f() = 0;
};
Suppose I wish to declare a function signature type returning this class:
using Type = A();
Given this code, gcc-4.8.2
failes with error
error: ‘type name’ declared as function returning an abstract class type
clang-3.3
compiles this nicely.
I tried to google this issue, but failed to find anything usefull. Is this code standard-compliant? If not, what is the reasoning behind forbidding declaring such signature type? I don't see any problems in just a declaration.
Disclaimer: I am NOT going to create instances of this type, I'm just interested in declaring a signature described.
For those interested in usefullness of such a declaration: I have some factory container that uses a signature like Interface(Arguments...)
when adding new factories to learn something about the new factory; the actual returned type is determined based on a separate traits class, parametrised by Interface
.
Obviously, I can just separate Interface
from signature, but it won't look that nice :(