I have used the std::enable_if
metafunction in my class template to specify that it is only allowed to generate classes for variables that have GameCard
as a base class. This works fine on its own when I implement the functions inline. However, if I want to implement the template functions outside the header body I run into the issue that I can't figure out how to correctly specify the function that I want to implement.
Cut down example code:
#include <string>
#include <memory>
#include <vector>
struct GameCard {};
template<class T, class = std::enable_if_t<std::is_base_of<GameCard, T>::value>>
struct CardStack {
std::vector<T> cards;
bool Test();
};
My IDE generates this as the function specification:
template<class T, class>
bool CardStack<T, <unnamed>>::Test() {
return false;
}
This is obviously wrong since I'm getting compiler errors. But I don't have a clue on how to do it right. Do any of you know how to do this right?