"SFINAE is Evil"
Jason House
jason.james.house at gmail.com
Sat Mar 22 02:32:55 PDT 2008
I look forward to when you can write more... Are you trying to say SFINAE is needed? I look at the examples and still think probably not. The traits example can be solved cleanly in D, just like enable if. The toughest one is the vector 2 example. I think detection of what is a vector 2 could be done with an interface? The rest of the examples I reaf are SFINAE free.
Bill Baxter Wrote:
> Jason House wrote:
> > I should probably expand this question...
> >
> > Who uses templates in D? What is the most complex use you've done? Do you ever plan to get more complex? Would SFINAE make your life easier or harder?
> >
> > I've written templates classes that have one definition, and used static if as needed for specialization. I don't forsee more complex usage and view SFINAE as something that would mask bugs.
>
> I don't have time to write more right now, but
> Lutz Kettner gives a pretty good examples of using SFINAE here:
> http://www.mpi-inf.mpg.de/~kettner/courses/lib_design_03/notes/meta.html#Constraining
> http://www.mpi-inf.mpg.de/~kettner/courses/lib_design_03/notes/meta.html#Classification
>
> Certainly the Enable_if template can be replaced by a simple static if.
> Maybe the other one too.
>
> The main problem I have with templates in D is that traits templates are
> severely limited by the inability to define specializations for a
> template in different modules. Like the IsVector_2 template Lutz talks
> about. If all specializations have to be in one file, then the library
> designer has to know in advance all the types that can ever be used as a
> Vector2 and clearly that limits the utility of it.
>
> Maybe this is coming in D2. I think I did a test recently and it still
> didn't work.
>
>
>
> --bb
More information about the Digitalmars-d
mailing list