digitalmars.D - Structs with a disabled default ctor can't pass as ranges
- Andrej Mitrovic <andrej.mitrovich gmail.com> Sep 24 2011
- "Steven Schveighoffer" <schveiguy yahoo.com> Sep 26 2011
I've ran into a bit of an issue. isInputRange is defined like this:
template isInputRange(R)
{
enum bool isInputRange = is(typeof(
{
R r; // can define a range object
if (r.empty) {} // can test for empty
r.popFront(); // can invoke popFront()
auto h = r.front; // can get the front of the range
}()));
}
But this will fail for structs which have a disabled default ctor. Was
this planned?
Sep 24 2011
On Sat, 24 Sep 2011 17:33:37 -0400, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:I've ran into a bit of an issue. isInputRange is defined like this: template isInputRange(R) { enum bool isInputRange = is(typeof( { R r; // can define a range object if (r.empty) {} // can test for empty r.popFront(); // can invoke popFront() auto h = r.front; // can get the front of the range }())); } But this will fail for structs which have a disabled default ctor. Was this planned?
I don't think this was planned. I think this should fix it: R r = R.init; -Steve
Sep 26 2011








"Steven Schveighoffer" <schveiguy yahoo.com>