2
我正在使用CRTP並且基類具有模板函數。我如何use
成員函數在模板派生類?「使用」指令如何與模板成員函數一起工作
template <typename T>
struct A {
int f();
template <typename S>
int g();
};
struct B: public A<B> {
int h() { return f() + g<void>(); } // ok
};
template <typename T>
struct C: public A<C<T>> {
// must 'use' to get without qualifying with this->
using A<C<T>>::f; // ok
using A<C<T>>::g; // nope
int h() { return f() + g<void>(); } // doesn't work
};
*編輯* 前面一個問題,Using declaration for type-dependent template name,包括評論,表明這是不可能的,可能是在標準的監督。
是的,你的另外兩條語句是我如何在不使用'使用'的情況下訪問g,但它們都非常麻煩!我希望'模板'的魔法咒語能讓我避開它們。 –