Difference between range `save` and copy constructor

uranuz neuranuz at gmail.com
Sun Feb 16 13:52:17 UTC 2020


It's very bad. Because there seem that when I use range based 
algorithm I need to take two things into account. The first is 
how algrorithm is implemented. If it creates copies of range 
inside or pass it by reference. And the second is how the range 
is implemented if it has value or reference semantics. So every 
time I need to look into implementation and I can't rely on API 
description in most of the cases. In a lot of cases Phobos uses 
value semantics. But there are cases where I want the range 
actually be consumed, but it's not. And the other problemme is 
when algorithm expects range to have value semantics, but it's 
not. So it's a buggy mess that it's hard to think about. In 
trivial cases this is working although. But in more complex cases 
it's simplier to implement some algorithms by own hands so that 
it would work as I expect it myself rather that thinking about 
all these value-ref-range mess. But still can't say that I 
implement it correctly, because range specification actually 
sucks as yo say.
It's just horrible


More information about the Digitalmars-d-learn mailing list