Re: how to define my own traits

2017-03-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 27 March 2017 at 21:18:31 UTC, XavierAP wrote: When I first read about inout as a device to obviate code duplication typical in C++ const ref overloads, I liked it but I assumed it was implemented by lowering it into the actual duplicate overloads. Though I'm not even sure right now

Re: how to define my own traits

2017-03-27 Thread XavierAP via Digitalmars-d-learn
On Monday, 27 March 2017 at 16:28:13 UTC, Gary Willoughby wrote: Even Andrei was baffled: http://forum.dlang.org/thread/nepm2k$311l$1...@digitalmars.com I see... And Walter went further and reported it as a DMD bug (still open clearly). It's what I mean. This strange behavior is more typic

Re: how to define my own traits

2017-03-27 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 26 March 2017 at 23:25:49 UTC, XavierAP wrote: I've looked into Phobos to emulate it when defining my own trait template, and when I see this: module std.range.primitives; // ... template isInputRange(R) { enum bool isInputRange = is(typeof( (inout int = 0) { R r

Re: how to define my own traits

2017-03-27 Thread XavierAP via Digitalmars-d-learn
On Monday, 27 March 2017 at 00:49:14 UTC, Moritz Maxeiner wrote: Have you tried it without the dummy parameter on the example given in the bug report [2]? I see, thanks for finding it! Looks a bit hacky but I can live with it. Indeed if I remove the argument from Phobos, Martin's example

Re: how to define my own traits

2017-03-26 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 26 March 2017 at 23:25:49 UTC, XavierAP wrote: I've looked into Phobos to emulate it when defining my own trait template, and when I see this: module std.range.primitives; // ... template isInputRange(R) { enum bool isInputRange = is(typeof( (inout int = 0) { R r

how to define my own traits

2017-03-26 Thread XavierAP via Digitalmars-d-learn
I've looked into Phobos to emulate it when defining my own trait template, and when I see this: module std.range.primitives; // ... template isInputRange(R) { enum bool isInputRange = is(typeof( (inout int = 0) { R r = R.init; // can define a range object if (r.em