October 07, 2017
Hello,

  I was implement my own range type that forwards all accesses to another range. I tried to write a `swap` function so that sort etc. could be called on my range. However, I cannot get `hasSwappableElements!ARange` to evaluate to true. But, when I copy pasted the definition of `hasSwappableElements` into my module and evaluated it, it was true. I assume this is something to do with how name lookup works in D. Here's simplified code that reproduces the same problem.

https://dpaste.dzfl.pl/48a420cce261

Thanks,
Balagopal.
October 07, 2017
On 10/07/2017 07:55 PM, Balagopal Komarath wrote:
>    I was implement my own range type that forwards all accesses to another range. I tried to write a `swap` function so that sort etc. could be called on my range. However, I cannot get `hasSwappableElements!ARange` to evaluate to true. But, when I copy pasted the definition of `hasSwappableElements` into my module and evaluated it, it was true. I assume this is something to do with how name lookup works in D. Here's simplified code that reproduces the same problem.
> 
> https://dpaste.dzfl.pl/48a420cce261

You can't provide your own swap function. `sort` etc. use std.algorithm.swap, so your range has to work with that.