On Wednesday, 24 September 2014 at 00:08:19 UTC, H. S. Teoh via
Digitalmars-d wrote:
You *will* need SFINAE if you expect to interface C++ template
libraries
with D. Imagine that an existing codebase is using some C++
template
library that depends on SFINAE. You'd like to start migrating
to D, so
you start writing new code in D. Eventually you need to make
use of the
C++ template library in order to interface with the C++ parts
of the
code, so you write a .di that declares template functions in an
extern(c++) block. It works... some of the time. Other times
you start
getting weird errors or the wrong functions get called, because
the C++
template library was written with SFINAE in mind, but D doesn't
have
that. So at the end of the day, it's a gigantic mess, and you go
crawling back to C++.
Unless, of course, we draw the line at templates and say that
we won't
support template compatibility with C++ (and I'd fully support
that
decision!). But that means we throw all C++ template libraries
out the
window, and any C++ codebase that makes heavy use of a template
library
will have to be rewritten from scratch in D.
I'm not a C++ guru, but it looks like SFINAE exists for
simplicity, so that templates can be matched without template
constraints and reflection. This looks equivalent to D template
constraints. If template doesn't work for some parameters, just
filter them out.