popFront with input variables
bearophile
bearophileHUGS at lycos.com
Fri Aug 31 08:38:21 PDT 2012
Joseph Rushton Wakeling:
> Is it considered legit in any circumstances for popFront to
> take an input variable (e.g. a random number generator)? Or is
> it required always to have no input variables?
popFront is meant to be called by foreach, or to be verified by
the isSomething compile-time tests of std.range. In both cases if
popFront takes an argument, it doesn't work. So I think it's not
a good idea.
struct Foo {
enum bool empty = false;
@property int front() { return 1; }
void popFront(int x) {}
//void popFront() {}
}
void main() {
import std.stdio;
foreach (i; Foo())
writeln(i);
}
temp.d(9): Error: function temp.Foo.popFront (int x) is not
callable using argument types ()
temp.d(9): Error: expected 1 function arguments, not 0
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list