[Issue 6221] Should be possible to pass struct function returns by 'const ref'.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 29 23:59:13 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6221
--- Comment #2 from Don <clugdbug at yahoo.com.au> 2011-06-29 23:54:17 PDT ---
(In reply to comment #1)
> I think this bug is invalid. A value-type return is an rvalue, and Andrei has
> made it very clear in his posts and in TDPL that rvalues cannot be bound to
> const ref parameters. I think his reasoning is that this ability was a mistake
> in C++, though I haven't gotten consistent answers as to why.
That's probably true. But that has consequences. We can't discard that C++
behaviour and yet keep the C++ behaviour of using const ref in operator
overloads:
> The fact that it works with opCmp in one direction is I think a relaxation of
> the rules, because struct returns would be near useless if you couldn't call
> any methods on them.
This is a serious problem. opCmp behaviour MUST be symmetrical.
S foo() {...}
S x;
x > foo()
foo() < x
foo() > foo()
If any of these compile, they must all compile.
As far as I can tell, a 'const ref' parameter on pretty much any operator
overload, is a bug. In fact it's difficult to come up with _any_ scenarios
where 'const ref' makes sense.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list