なぜ以下はコンパイルされませんか?テンプレート化された親からの子のtypedefへのアクセス
template <typename Child> struct Base
{
typename Child::Type t; // Does not compile. "No type named Type in Child"
};
struct Derived : public Base<Derived>
{
typedef int Type;
};
どのようにBase
はチャイルドタイプにアクセスできないのですか?私はtypedefの代わりに静的関数を使って同じことを試みましたが、うまくいきました。
私はGCC 4.4.2とclang 3.0の両方を試しました。
[C++静的多型(CRTP)と派生クラスのtypedefを使用する可能性のある複製](http://stackoverflow.com/questions/6006614/c-static-polymorphism-crtp-and-using-typedefs-from-derived -クラス) – thirtythreeforty