mercredi 9 juin 2021

Overload that still compiles if parameter type doesn't exist

I have a function like so:

template <typename T>
void modify(T& x) {
  ...
}

I would like to add an overload specialized for the type __m256i, like so:

void modify(__m256i& x) {
  ...
}

However, this poses the problem that this definition will fail to compile if the type __m256i doesn't exist, but I'd like this header to still compile in that case, just with that overload (logically) omitted. After all, the __m256i overload won't be useful if the user hasn't included a definition of that type.

Aucun commentaire:

Enregistrer un commentaire