テンプレートクラスを使用して実装パターンへのポインタを実装しようとしています。独立したクラスとその実装を作成するために、次のアプローチを使用します。
template<typename T>
struct __A_impl;
template<typename T>
struct A
{
using __impl_t = __A_impl<T>;
A(__impl_t* t);
__impl_t* _t;
};
template<typename T>
struct B
{
T _t;
};
template<typename T>
using __A_impl = B<T>;
このフォームでは、「B」の名前を変更したい場合、これはAの定義にはまったく影響しません。しかし、gccで次のエラーが発生します。
test.cpp:21:22: error: declaration of template 'template<class T> using __A_impl = B<T>'
test.cpp:2:7: error: conflicts with previous declaration 'template<class T> class __A_impl'
test.cpp:21:22: error: redeclaration of 'template<class T> using __A_impl = B<T>'
test.cpp:2:7: note: previous declaration 'template<class T> class __A_impl'
どうすればこれを達成できますか?typedef
宣言者では不可能だからです。