Re: Range over a container r-value with disabled postblit

2018-01-14 Thread Andrei Alexandrescu via Digitalmars-d-learn
On 1/14/18 4:59 PM, Nordlöw wrote: On Sunday, 14 January 2018 at 21:57:37 UTC, Nordlöw wrote: Note that __trait(isLvalue, this) cannot be used to detect whether `this` is an l-value or an r-value, which I find strange. Shall be __traits(isRef, this) That would be difficult because lval/rval

Re: Range over a container r-value with disabled postblit

2018-01-14 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 14 January 2018 at 21:57:37 UTC, Nordlöw wrote: Note that __trait(isLvalue, this) cannot be used to detect whether `this` is an l-value or an r-value, which I find strange. Shall be __traits(isRef, this)

Re: Range over a container r-value with disabled postblit

2018-01-14 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 14 January 2018 at 14:04:46 UTC, kinke wrote: That sounds reasonable. For something like `foreach (e; makeRange().wrapRangeByRef())`, referencing the makeRange() struct rvalue by pointer in the wrapped range won't work, as the underlying range lifetime ends with the foreach range ex

Re: Range over a container r-value with disabled postblit

2018-01-14 Thread kinke via Digitalmars-d-learn
On Sunday, 14 January 2018 at 01:38:17 UTC, Nordlöw wrote: My current proposal for a solution is to make `byElement` a free unary function byElement(auto ref X x) which statically checks via static if (__traits(isRef, x)) whether the `X`-instance is passed as either an - l-value, wh

Range over a container r-value with disabled postblit

2018-01-13 Thread Nordlöw via Digitalmars-d-learn
Given my combined hashmap and hashset container `HashMapOrSet` defined at https://github.com/nordlow/phobos-next/blob/master/src/hashmap_or_hashset.d with deterministic memory management and disabled copy constructions and a member byElement() defined as @property auto byElement()()