Should this work?

John Colvin john.loughran.colvin at gmail.com
Fri Jan 10 12:23:31 PST 2014


On Friday, 10 January 2014 at 20:08:32 UTC, Atila Neves wrote:
> I expected popFront at first to return the popped element as 
> well, and would use a function like that. You're not alone. 
> But... like you did, I'd just define my own convenience 
> function and UFCS keeps everything readable so no biggie. But 
> something in Phobos would be better, methinks. std.range.take 
> is similar, but not the same since it returns a range and not 
> an element. Also, it requires passing in the very common "1" as 
> an argument.

It's not ideal as full-speed performance depends on the Take 
struct being optimised away, but there is always:

auto blah  = range.takeOne.front;


More information about the Digitalmars-d mailing list