Ranges: is it ok if front is a data member?

Ali Çehreli acehreli at yahoo.com
Thu Dec 12 08:32:41 PST 2013


On 12/12/2013 08:19 AM, Adam D. Ruppe wrote:

 > Consider the following:
 >
 > struct JustZeroes {
 >      int front = 0;
 >      enum bool = false;

You meant empty = false;

 >      void popFront() {}
 > }
 >
 > Is that guaranteed to work as an input range?

Yes it is perfectly fine. And if it works for empty it should work for 
front. ;) The presence of std.range.hasLvalueElements is another 
indicator that it fine. Finally, if std.range.isInputRange returns true, 
it is an InputRange.

Ali



More information about the Digitalmars-d-learn mailing list