C++ guys hate static_if?
Dmitry Olshansky
dmitry.olsh at gmail.com
Fri Mar 15 04:27:46 PDT 2013
15-Mar-2013 06:43, deadalnix пишет:
> On Thursday, 14 March 2013 at 23:52:59 UTC, Nick Sabalausky wrote:
>> On Thu, 14 Mar 2013 17:54:52 -0400
>> Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
>>>
[snip]
>> That implicitly does the equivalent of ".save" on a mere InputRange
>> *twice*. The result, of course, is completely dependent on the input
>> range in question.
>
> Passing range by value is completely undefined, which is IMO a big weak
> spot of ranges.
What can be done in the mean time is stating somewhere prominent this:
Given InputRanges a & b:
1. a = b; //now 'a' can only be *either* an alias of 'b' or 'a' is a
copy of 'b'
2. a = move(b); //now a is the only copy (the only alias ;))
3. a = b.save(); //now a is guaranteed to be a shallow copy
By copy here it's implied that range preserves iteration state. The
underlying values may be changed elsewhere.
There could be some argument to make 1 always do 3 and trim it to 2
rules. But ehm, sorry, classes as ranges can't do that so we are stuck.
If I had to choose I'd drop the current OOP support of D in favor of
simplifying things (only half-joking) :)
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list