2

I have a template class where the template definition if very long

template<typename firstType, typename secondType, typename thirdType, typename fourthType, typename fifthType, typename sixthType>

In the .cpp file, writing this entire template in front of each function definition is long and make reading a little difficult. Consider this set function

template<typename firstType, typename secondType, typename thirdType, typename fourthType, typename fifthType, typename sixthType>
void myClass<firstType, secondType, thirdType, fourthType, fifthType, sixthType>::set(firstType x)
{
   ...
}

It would be nice to be able to do

TEMPLATEDEFINITIONS
void myClass<MYTEMPLATES>::set(double x)
{
   ...
}

instead and the compiler would somehow knows to replace TEMPLATEDEFINITIONS and MYTEMPLATES with the appropriate strings. Is something like that possible (without having to sed in the makefile)?

Remi.b
  • 17,389
  • 28
  • 87
  • 168

0 Answers0