I want to overwrite a type with a typedef. The rationale for doing this is that one of my class has lot of templates and i want to replace all calls to that class with the templatized class (so that within another class Achild
means Achild<T>
. However, i get an error.
template <typename T>
class Achild
{
public:
Achild<T>() = default;
};
class Foo
{
typedef Achild<int> Achild;
public:
Foo() = default;
};
int main()
{
auto foo = new Foo();
}
I get the following error:
new_test.cpp:12:22: error: declaration of ‘typedef class Achild<int> Foo::Achild’ [-fpermissive]
typedef Achild<int> Achild;
^~~~~~
new_test.cpp:2:10: error: changes meaning of ‘Achild’ from ‘class Achild<int>’ [-fpermissive]
class Achild
How can i get this to work? The example is only for sample and my reasons for doing this is also related to how i have to get this to work with an existing codebase.