@nogc inconsistent for array comparison depending on mutability of elements

Nick Treleaven via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 8 04:45:25 PDT 2016


On Friday, 8 April 2016 at 10:11:43 UTC, Rene Zwanenburg wrote:
> On Friday, 8 April 2016 at 09:56:41 UTC, Nick Treleaven wrote:
>> If the comparison with b shouldn't be allowed, I suggest we 
>> add opEquals to std.range.only. This removes a need to import 
>> std.algorithm.equal and reduces bracket nesting:
>>
>> assert(b == only(1, 2));
>
> equal[1] can compare ranges of different types.

opEquals would too. Not sure what you're saying. It wouldn't 
replace equal, only equal(only()). Pun intended.

> It's a bit less clear than the original code though.
>
> b.equal(only(1, 2));

I'd argue the opposite.

>
> [1] http://dlang.org/phobos/std_algorithm_comparison.html#.equal




More information about the Digitalmars-d-learn mailing list