子类中,怎么访问模板父类内的类型定义

子类中,如何访问模板父类内的类型定义
template<class D>
struct B {
typedef typename D::type type; // 1, 此处无法通过编译
type get_default() { return type(); }
};

template<class T>
struct D : public B<D<T>>
{
typedef T type;  //2, type在此有public定义
};

#include <assert.h>
void test()
{
D<int> d;
assert(d.get_default()==0);
}

请问如何解决?
------解决思路----------------------
编译器在处理类模板D的时候,从类模板B的一个实例化派生。
但是这个时候,D的一个实例化只有类名,没有实现,也就是说
typedef typename D::type type;的时候D<int>对类模板B是不可见的
引入一个中间层就好了


template <typename T>
struct Traits;

template 
<
typename T,
template <typename> class P
>
struct Traits <P<T>>
{
typedef T type;
};

template<class T>
struct D : public B<D<T>>
{
typedef T type;  //2, type在此有public定义
};

template <typename D>
struct B
{
typedef typename Traits<D>::type type;
//typedef typename D::type type;
type get_default() const { return type(); }
};