Implementing swap for user-defined swaps

Balagopal Komarath baluks at gmail.com
Sat Oct 7 17:55:08 UTC 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.


More information about the Digitalmars-d-learn mailing list