Ваш пример кода недействителен, AFAIK. Мне пришлось применить следующие изменения, чтобы исправить некоторые ошибки:
--- nested.cxx.orig 2011-11-01 16:58:30.234375000 +0100
+++ nested.cxx 2011-11-01 17:00:13.781250000 +0100
@@ -9,12 +9,12 @@ struct Base
template <class U=ExtendHelper>
struct Type
:
- T::Type<U>,
+ T::template Type<U>,
Extender
{
- Type(typename T::Type<T> &rhs)
+ Type(typename T::template Type<T> &rhs)
:
- T::Type<U>(rhs)
+ T::template Type<U>(rhs)
{
}
Type() {}
@@ -24,12 +24,12 @@ struct Base
template <class Extender>
struct Extend
:
- ExtendHelper<Extender>::Type<>
+ ExtendHelper<Extender>::template Type<>
{
template <class C>
Extend(C &rhs)
:
- ExtendHelper<Extender>::Type<>(rhs)
+ ExtendHelper<Extender>::template Type<>(rhs)
{
}
};
После изменений я получаю это:
g++ -Wextra -Wall -pedantic -std=c++98 -c nested.cxx
nested.cxx: In constructor ‘Base::Type<T>::ExtendHelper<Extender>::Type<U>::Type(typename T::Type<T>&) [with U = Base::Type<Base>::ExtendHelper<Data>, Extender = Data, T = Base, typename T::Type<T> = Base::Type<Base>]’:
nested.cxx:32:60: instantiated from ‘Base::Type<T>::Extend<Extender>::Extend(C&) [with C = Base::Type<Base>, Extender = Data, T = Base]’
nested.cxx:42:49: instantiated from here
nested.cxx:17:44: error: no matching function for call to ‘Base::Type<Base::Type<Base>::ExtendHelper<Data> >::Type(Base::Type<Base>&)’
nested.cxx:5:5: note: candidates are: Base::Type<Base::Type<Base>::ExtendHelper<Data> >::Type(const Base::Type<Base::Type<Base>::ExtendHelper<Data> >&)
nested.cxx:5:5: note: Base::Type<Base::Type<Base>::ExtendHelper<Data> >::Type()