Q:

How can I implement a class template function with a std::enable_if metafunction?

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?

A:

Out of class definition should be:
template<class T, class Enabler>
bool CardStack<T, Enabler>::Test() {
  return false;
}

But currently, you class might be hijacked:
Whereas CardStack<int> or CardStack<int, void> won't compile thanks to SFINAE,
CardStack<int, char> would be "valid" (risk to not compile because of hard error produced by int in CardStack implementation).
static_assert seems enough in your case:
template<class T>
struct CardStack {
  static_assert(std::is_base_of<GameCard, T>::value);

  std::vector<T> cards;
  bool Test();
};

With simpler out of class definition:
template<class T>
bool CardStack<T>::Test() {
  return false;
}

