Why can’t a class have a decltype in the inheritance list? For instance, I would expect the following code to make A<B> inherit from RType, but with G++ 4.6.1 (using -std=c++0x) it does not compile:
#include <type_traits>
template<typename T>
class A : public decltype(std::declval<T>().hello()) { };
class RType { };
class B {
public:
RType hello() { return RType(); }
};
int main() {
A<B> a;
}
It gives the following output:
test.cpp:6:18: error: expected class-name before 'decltype'
test.cpp:6:18: error: expected '{' before 'decltype'
test.cpp:6:54: error: expected unqualified-id before '{' token
test.cpp: In function 'int main()':
test.cpp:16:7: error: aggregate 'A<B> a' has incomplete type and cannot be defined
The use of declval is just to provide an instance where you needed to use decltype, but other uses of decltype also fail (that is, without declval).
It’s allowed :
10.1 : “A list of base classes can be specified in a class definition using the notation:”
so I guess your compiler has bug