July 07, 2014Re: How to test templates for equality?
Posted in reply to Philippe Sigaud
> In this particular case, the only solution I know of is an awful hack: > using .stringof and __traits(identifier, x) and then parse the > strings: > > "Name!(int, double[string])" and "Name(T, U[V], U, V)" > > and then the fun begins: in the general case, you must then equate the > arguments lists (recursively). > > Philippe Yes. This is possible solution but looks very complicated. For now I changed it for struct template. But there are could be some cases where you don't want to make it class or struct (theoreticaly). If someone else experience the same problem, so may be new __traits(...) needs to be proposed. We have the only trait isSame that helps working with templates. May be we could add trait that will help get template arguments list for instantiated template. I think it could be useful.
Copyright © 1999-2017 by the D Language Foundation