Should this work?
John Colvin
john.loughran.colvin at gmail.com
Fri Jan 10 07:19:38 PST 2014
On Friday, 10 January 2014 at 15:05:18 UTC, monarch_dodra wrote:
> On Friday, 10 January 2014 at 14:31:31 UTC, John Colvin wrote:
>> or if you want something short and simple, define a free
>> function:
>> auto popFrontRet(R)(ref R range)
>> if(isInputRange!R)
>> {
>> range.popFront();
>> assert(!range.empty);
>> return range.front;
>> }
>
> *Unless* I'm mistaken, he was asking for something that returns
> the *popped* element?
>
> Re-reading the question, it does kind of sound a bit ambiguous
> now.
Woops, of course:
auto popFrontRet(R)(ref R range)
if(isInputRange!R)
{
auto tmp = range.front;
range.popFront();
}
That also invalidates my second point to do with emptiness.
More information about the Digitalmars-d
mailing list