追加機能のない型を作成するときusing
は、サブクラス化や を使用するのではなく、を使用するようにしていtypedef
ます。
具体的な型をツリーに伝播しようとしている CRTP 階層があります。
GrandKid
うまくコンパイルできるようです。GrandKid_2
仕事に行く方法はありますか?
エラーメッセージ
junk.cpp:18:26: error: ‘GrandKid_2’ was not declared in this scope
コード
template<typename T>
struct Parent
{
};
template<typename T>
struct Child
: public Parent<T>
{
};
struct GrandKid :
public Child<GrandKid>
{
};
// using GrandKid_2 = Child<GrandKid_2>; // doesn't compile
int
main( int argv, char* argc[] )
{
GrandKid gk; // ok
}