mardi 23 août 2022

C++ 11 conditional template alias to function

In C++ 11, I want to make a template alias with two specializations that resolve to a different function each.

void functionA();
void functionB();

template<typename T = char>
using Loc_snprintf = functionA;

template<>
using Loc_snprintf<wchar_t> = functionB;

So I can call e.g. Loc_snprintf<>() and it's resolve to functionA().

Apparently seems impossible (to compile). Is there something ultimately simple that mimics it (maybe using a class template)?

Aucun commentaire:

Enregistrer un commentaire