In the beginning of my engeenering school, my teachers introduced me to a particular use of macros in C++ : when declaring template classes, they told me to create a macro that abstracts the template parameters of methods definitions.
For example, if i have a class named MyList which is a list of element of type T, and i have a method :
template<typename T>
void MyList<T>::add(T element);
They encouraged us to create the following macros in the cpp file :
define TEMPL template<typename T>
define MY_LIST MyList<T>
So as the method definition becomes :
TEMPL void MY_LIST::add(T element);
Hence, if i decide to change the template parameters, i only have to change the macro definition. Do you also think that this is a good practice? Recently i also started to use it to abstract the namespace in method definitions, would you recommend it? And if you wouldn't, why?
I have also another problem with this practice, it is that Visual Studio does not recognize the methods definitions in the cpp file due to the use of the macro. In the header file, the methods declarations are underlined with a message 'Function definition not found', despite the code compile. If it is a good practice, is there a way to remove these warnings?
Thanks you in advance.