templating opEquals/opCmp (e.g. for DSL/expression templates)
Atila Neves
atila.neves at gmail.com
Tue Feb 12 11:45:09 UTC 2019
On Tuesday, 12 February 2019 at 11:35:28 UTC, Nicholas Wilson
wrote:
> On Tuesday, 12 February 2019 at 10:37:22 UTC, Jonathan M Davis
> wrote:
>> Having the meaning be different is precisely the problem. It's
>> using the syntax for something _other_ than what it's intended
>> for. It's just supposed to be a way to have user-defined types
>> emulate the operations of built-in types. Walter has mentioned
>> time and time again how he thinks that stuff like << in C++
>> where they made the operators mean something completely
>> different than what they mean for built-in types was a big
>> mistake, and personally, I agree.
>
> I agree using << for I/O is stupid.
I've never understood this argument. I've never met anyone who
was confused by this. Personally, I read it as "shove". C++20
ranges use `|` as a pipe operator instead of bitwise or, and not
only does it make sense, I don't think anybody's complaining
about that either.
> The use case is e.g. building a DB query predicate where ==
> still means equality not e.g. I/O, it just isn't evaluated
> directly. The fact is you can already use it for arithmetic to
> build e.g. linear algebra expression templates, and you can use
> == predicates but not != or any of the ordering comparisons is
> inconsistent arbitrary and annoying.
Agreed.
More information about the Digitalmars-d
mailing list