简体   繁体   中英

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

即使您完全专门化模板,您仍然需要template<>

template<> template<> void ClassA<int>::Execute<2>() { //Do stuff    }

You forgot to tell the compiler that you're specializing a template method of a template class:

template <>
template <>
void ClassA<int>::Execute<2>()
{
    //Do stuff
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM