I would like tag dispatch because:
- Easy to extend with new tags
- Easy to use inheritance (example)
- It is fairly common technique in generic programming
It seems tricky to me to add third variant in second example. When you’ll want to add, for example non-POD-of-PODs type you’ll have to replace bool
in template <typename T, bool> struct f2;
with something other (int
if you like =) ) and replace all struct f2<T, bool-value>
with struct f2<T, another-type-value>
. So that for me the second variant looks hardly extensible. Please correct me if I wrong.