[Issue 14593] New: operator overloading can't be used with expression templates

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat May 16 06:41:26 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14593

          Issue ID: 14593
           Summary: operator overloading can't be used with expression
                    templates
           Product: D
           Version: unspecified
          Hardware: Other
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: code at dawg.eu

A motivating example is using expression templates to specify db queries.

db.get!Person.where!(p => p.age > 21 && p.name == "Peter")

This has the following problems:
- opCmp doesn't allow to capture the op
- it's not possible to overload &&
- opEquals must return a bool (but here it needs to return p)

A solution would be to use the generic opBinary for < <= > >= == iff
opCmp/opEquals don't exist and also extending it to && ||.

--


More information about the Digitalmars-d-bugs mailing list