Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22198

Can I use a templated Type Alias for defining a Template Class' Methods in C++ with GCC?

$
0
0

Sometimes I like my template class method definitions in a source file (or second header) to reduce build times. In all my source files I use a type alias for the class I'm defining the methods of to keep repetitions and typing time at a minimum.

Simple example:

// Foo.hclass Foo{ void bar(); }
// Foo.cppusing _ = Foo;void _::bar(){}

I have done this for template classes, which I want to keep the template parameter open of in method definitions, using MSVC.

// Foo.htemplate<typename T>class Foo{ void bar(); }
// Foo.cpptemplate<typename T>using _ = Foo<T>;template<typename T>void _<T>::bar(){}

However, while MSVC accepts this, GCC (12.2.0, MinGW) doesn't (invalid use of incomplete type). Am I maybe just doing it the wrong way or is it just not possible?


Viewing all articles
Browse latest Browse all 22198

Trending Articles