Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

template class with Non-type template Parameter member function

I am trying to define a specialization of a template class which contains a Non-type template Parameter member function. And I get the following error:

error: too few template-parameter-lists

Here's a sample class that describes the problem in brief,
// file.h
template <typename T>
class ClassA {
  T Setup();
  template <int K> static void Execute();
};

//file.cc
void ClassA<int>::Execute<2>() { //Do stuff    }

I believe this is more of a syntax issue than a design issue, any clues? Thanks

like image 219
Chenna V Avatar asked Dec 04 '25 10:12

Chenna V


1 Answers

Even if you fully specialize a template, you still need template<>:

template<> template<> void ClassA<int>::Execute<2>() { //Do stuff    }
like image 121
Dark Falcon Avatar answered Dec 06 '25 23:12

Dark Falcon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!