継承階層のもう一方の端にあるテンプレートクラスから基本クラスのメンバーのメンバー関数を呼び出そうとすると、
class memberobj {public: void bar(){}};
class basis {public: memberobj foo;};
template<class Base, class Derived>
class crtp : public Base { /* ... */ };
template<class Option>
class choice : crtp< basis, choice<Option> > {
using basis::foo;
public:
void test () {foo.bar();}
};
class someoption {};
int main() {
choice<someoption> baz;
baz.test();
return 0;
}
このエラーメッセージが表示されます:
g++-4.6 -o bin/crtptest crtptest.cpp
crtptest.cpp: In member function ‘void choice<Option>::test()’:
crtptest.cpp:12:21: error: ‘class basis’ has no member named ‘bar’
make: *** [bin/crtptest] Error 1
bar
明らかに、それ自体ではなく、のメンバーのメンバー です。これは、非テンプレートの最終クラス(その数はすでに使用されており、すべて中間クラスから派生しているため、これについては何も変更したくない)や、から直接派生するテンプレートクラスでは発生しません。basis
basis
crtp
basis
ここで何が問題になっていますか?