C++ guys hate static_if?
monarch_dodra
monarchdodra at gmail.com
Sat Mar 9 08:22:42 PST 2013
On Saturday, 9 March 2013 at 16:05:59 UTC, Andrei Alexandrescu
wrote:
> On 3/9/13 10:22 AM, monarch_dodra wrote:
>> BTW, in regards to template constraints (not the rest), he
>> does have a
>> point. We have raised the exact same issues here on the boards
>> more than
>> once.
>
> What was the problem for D again?
>
> Andrei
"Problem" is a big word. But basically, the combination: "if your
template type doesn't meet template constraints, where did it
fail?" We don't have that, but concepts do. This is part of the:
- Should we use constraints only for overloads or also to
validate types?
- Should we instead use static asserts to find out why the
argument type is wrong?
That said, concepts (afaik) don't handle overloads...
...which brings us to managing said overloads. Basically, right
now, if you want overloads, you have to repeat the conditions in
a:
if (a && !b)
...
if (b && !c)
...
if (c)
This is minor, but it does not scale very well, especially if
"a", "b" and "c" are complicated. In algorithm, some of our
constraints for sort/find can be 5 lines long. At this point, can
we still say that they are readable tools for users, or an
implementation tool for dispatch?
Things can get evenmore hairy,when you are operating on 2
different types.
One last thing to keep in mind is that having constraints allows
hijacking, whereas concpets/static asserts resolve as an ambigus
call.
----
Not a breaking issue or anything, just more of an anoyance. I
wanted to point out that we ourselves have already had talks
about the points raised in said article.
Regardless, that was not the main point that I was trying to get
accross. My main point was simply that what works for D might not
be best for C++.
More information about the Digitalmars-d
mailing list