digitalmars.D.bugs - [Issue 7706] New: Comparing struct rvalues
- d-bugmail puremagic.com (35/35) Mar 13 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7706
- d-bugmail puremagic.com (6/6) Mar 13 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7706
- d-bugmail puremagic.com (7/7) Mar 13 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7706
http://d.puremagic.com/issues/show_bug.cgi?id=7706
Summary: Comparing struct rvalues
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: spec
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: k.hanazuki gmail.com
PDT ---
The spec says in operatoroverloading.dd:
| Comparison operations are rewritten as follows:
| ``a < b'' to ``a.opCmp(b) < 0'' or ``b.opCmp(a) > 0''
and
| If structs declare an opCmp member function, it should follow the following
form:
|
| struct S {
| int opCmp(ref const S s) const { ... }
| }
If you follow these specs, you cannot accept comparison between two rvalues.
For example S(0) < S(1), which is rewritten as S(0).opCmp(S(1)), is rejected
_correctly_ by current DMD implementation (2.059HEAD).
In order to resolve this problem, comparison operators on struct types must be
translated as follows:
a < b
to (const _tmpb = b), a.opCmp(_tmpb) < 0
or (const _tmpa = a), b.opCmp(_tmpa) > 0
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 13 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7706 PDT --- Forgot to mention there is the same problem with opEquals and ==/!=. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 13 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7706 PDT --- ah, my idea improves nothing than allowing rvalue-to-const-ref conversion. forget about it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 13 2012









d-bugmail puremagic.com 