If the only use cases that you (will) have are
char[4]
, char[4], uint16_t
, and float
,
then following the advice of
@Jarod42 and @463035818_is_not_an_ai
is enough.
If there's more,
and since you have used the tag oop,
I propose the following option:
Instead of enumerating your Tags
,
define a small class for each Tag
item,
and have a virtual method for handling t
.
Delegate handling what to do with t
in the classes you derive from here.
A partial answer would be as follows:
template <typename T>
class Tag {
public:
virtual void operator() (T& t) = 0;
};
template <typename T>
class A : public Tag<T> {
public:
void operator() (T& t) override {
printf("D: A::operator()\n");
}
};
template <typename T>
class B : public Tag<T> {
public:
void operator() (T& t) override {
printf("D: B::operator()\n");
}
};