У меня две структуры:
// ----- non-const -----
struct arg_adapter
{
EArgType type; // fmtA, fmtB, ...
union
{
TypeA * valueA;
TypeB * valueB;
// ... more types
}
arg_adapter(TypeA & value) : type(fmtA), valueA(&value) {}
arg_adapter(TypeB & value) : type(fmtB), valueB(&value) {}
// ...
}
// ----- const version -----
struct const_arg_adapter
{
EArgType type; // fmtA, fmtB, ...
union
{
TypeA const * valueA;
TypeB const * valueB;
// ... more types
}
arg_adapter(TypeA const & value) : type(fmtA), valueA(&value) {}
arg_adapter(TypeB const & value) : type(fmtB), valueB(&value) {}
// ...
}
Они должны использоваться в таких методах, как:
Convert(const_arg_adapter from, arg_adapter to)
Есть несколько TypeX (около 5, может стать больше), большинство из них примитивны. Это делается для того, чтобы не поддерживать разные прототипы.
Теперь мой вопрос; -)
Есть ли способ сделать константу параметром шаблона? Моя цель - поддерживать только одну структуру, т.е.
template <Qualifier CONSTNESS>
struct arg_adapter_t
{
...
CONSTNESS TypeA * valueA;
...
}