
On 09/04/11 05:14, Gennadiy Rozental wrote:
This has at least 2 problems:
1. It does not work. I need "scalar" level specialization to be applied if enum level specialization is not present. In your case it will not even compile. Or it will choose incorrect (generic) option if you non specialized version for that. We can try to follow STL's approach of iterator tag dispatching based on hierarhy, but that really cumbersome and require extra runtime wrappers.
I can be doen using compile-time stuff, no need for runtime.
2. It's intrusive. Once I introduce new subgroup of types I need to go in common header and update tag selection (and potentially something else to handle relation with other groups)
We faced this exact same problem in NT2 and we ended up having a whole component dedicated to complex, multiple arguments, hierarchical traits dispatching. This is a non trivial problem and it gets out of hand fast once you want to add new types familly and still be extensible. Our solution rely on having a "hierarchy" traits defined for types and use operator overload detection meta-function to select the proper hierarchy from : the actual type and the actual existence of an overload. We use this exact system in our SIMD library, so it may be of interest to make it a proper reusable component.