www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Restrict Combination of moveFront and popFront to Suitable Element

reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
As a follow-up question to

http://forum.dlang.org/thread/jkbhlezbcrufowxtthmy forum.dlang.org?page=3#post-zyuqclyjitbhavemmwto:40forum.dlang.org

discussing the motivation for a new range primitive stealFront 
that combines moveFront and popFront implemented at

https://github.com/nordlow/justd/blob/master/range_ex.d#L14

I then wonder if there's a way to check, using a type-trait, 
whether the value returned from moveFront is safe to use after 
popFront has been called on it. If so I want to restrict 
stealFront/Back with this trait.
Nov 01 2014
next sibling parent reply "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> writes:
On Saturday, 1 November 2014 at 21:26:49 UTC, Nordlöw wrote:
 As a follow-up question to

 http://forum.dlang.org/thread/jkbhlezbcrufowxtthmy forum.dlang.org?page=3#post-zyuqclyjitbhavemmwto:40forum.dlang.org

 discussing the motivation for a new range primitive stealFront 
 that combines moveFront and popFront implemented at

 https://github.com/nordlow/justd/blob/master/range_ex.d#L14

 I then wonder if there's a way to check, using a type-trait, 
 whether the value returned from moveFront is safe to use after 
 popFront has been called on it. If so I want to restrict 
 stealFront/Back with this trait.
Not currently, but see my proposal: http://wiki.dlang.org/User:Schuetzm/scope#scope.21.28const_....29
Nov 02 2014
parent =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
On Sunday, 2 November 2014 at 11:55:41 UTC, Marc Schütz wrote:
 On Saturday, 1 November 2014 at 21:26:49 UTC, Nordlöw wrote:
 As a follow-up question to

 http://forum.dlang.org/thread/jkbhlezbcrufowxtthmy forum.dlang.org?page=3#post-zyuqclyjitbhavemmwto:40forum.dlang.org

 discussing the motivation for a new range primitive stealFront 
 that combines moveFront and popFront implemented at

 https://github.com/nordlow/justd/blob/master/range_ex.d#L14

 I then wonder if there's a way to check, using a type-trait, 
 whether the value returned from moveFront is safe to use after 
 popFront has been called on it. If so I want to restrict 
 stealFront/Back with this trait.
Not currently, but see my proposal: http://wiki.dlang.org/User:Schuetzm/scope#scope.21.28const_....29
Thanks. A trivial solution, but probably too great restriction, would be auto stealFront(R)(ref R r) if (!hasIndirections!(ElementType!R)) a smaller restriction would be to use auto stealFront(R)(ref R r) if (!hasUnsharedAliasing!(ElementType!R)) Can hasUnsharedAliasing be used in my case? For detail see - http://dlang.org/phobos/std_traits.html#hasIndirections - http://dlang.org/phobos/std_traits.html#hasUnsharedAliasing
Nov 02 2014
prev sibling parent =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Saturday, 1 November 2014 at 21:26:49 UTC, Nordlöw wrote:
 https://github.com/nordlow/justd/blob/master/range_ex.d#L14
Moved here https://github.com/nordlow/phobos-next/blob/master/src/range_ex.d#L66
May 11 2016