Re: Passing Templated Function Arguments Solely by Reference

2014-07-13 Thread Nordlöw
On Friday, 11 July 2014 at 17:43:53 UTC, Ali Çehreli wrote: Ali Thx

Re: Passing Templated Function Arguments Solely by Reference

2014-07-11 Thread Ali Çehreli via Digitalmars-d-learn
On 07/11/2014 03:38 AM, "Nordlöw" wrote: > https://github.com/nordlow/justd/blob/master/random_ex.d > > is what I have so far. Does this look ok to you? The following seems redundant because the other isFloatingPoint!E version uses the default arguments 0 and 1 anyway. auto ref randInPlace(E)

Re: Passing Templated Function Arguments Solely by Reference

2014-07-11 Thread Nordlöw
On Wednesday, 9 July 2014 at 07:43:57 UTC, Ali Çehreli wrote: Ali This https://github.com/nordlow/justd/blob/master/random_ex.d is what I have so far. Does this look ok to you? Question: Can I somehow avoid the duplication of logic in - auto ref randInPlace(R)(R x) @safe if (hasAssignableEl

Re: Passing Templated Function Arguments Solely by Reference

2014-07-11 Thread Nordlöw
On Wednesday, 9 July 2014 at 07:43:57 UTC, Ali Çehreli wrote: Phobos algorithms use ranges. The following is what I've come up with very quickly: Thx

Re: Passing Templated Function Arguments Solely by Reference

2014-07-09 Thread Ali Çehreli via Digitalmars-d-learn
On 07/08/2014 05:13 PM, "Nordlöw" wrote: > If I want randInPlace to take value arguments (such as structs) by > reference and reference types (classes) as normal is this I don't understand what it means to fill a struct or a class object with random content. > /** Generate Random Contents in

Re: Passing Templated Function Arguments Solely by Reference

2014-07-08 Thread Nordlöw
On Wednesday, 9 July 2014 at 00:13:41 UTC, Nordlöw wrote: Searching for "Function Templates with Auto Ref Parameters" on http://dlang.org/template.html answered my first question. I'm however still uncertain how to implement randInPlace in the most D idiomatic way.

Passing Templated Function Arguments Solely by Reference

2014-07-08 Thread Nordlöw
If I want randInPlace to take value arguments (such as structs) by reference and reference types (classes) as normal is this /** Generate Random Contents in $(D x). */ auto ref randInPlace(T)(auto ref T x) @safe /* nothrow */ if (isIterable!T) { foreach (ref elt; x) { import s