我剛剛更新到4.8.2 GCC(4.7),我現在得到了下面的代碼警告:如何定義模板的模板化子類?
template <class T_base>
class factory {
private:
template <class T>
struct allocator : factory {
//^warning: invalid use of incomplete type 'class factory<T_base>'
};
};
爲了避免該警告,我試圖定義factory
struct allocator
之外,但現在得到出現以下錯誤:
template <class T_base>
class factory {
private:
template <class T>
struct allocator;
};
template <class T_base, class T>
struct factory<T_base>::allocator<T> : factory<T_base> {
//^error: too few template-parameter-lists
};
我在做什麼錯?是否有上述構造的語法避免了警告和錯誤?
現在有道理我知道需要什麼:)謝謝! – zennehoy
在這個上下文中'factory'不是_nested-type-name_(或其他)>有點煩人。< –