[Issue 5935] Non-tuple iteration with std.range.zip
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon May 9 10:22:44 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5935
Lutger <lutger.blijdestijn at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lutger.blijdestijn at gmail.co
| |m
--- Comment #5 from Lutger <lutger.blijdestijn at gmail.com> 2011-05-09 10:18:44 PDT ---
If no language changes for range iteration and tuple unpacking will be made,
perhaps it's worth to consider a generic wrapper for this purpose as a
compromise?
I couldn't think of a good name:
auto iterUntupled(R)(R input)
if ( isInputRange!R &&
is( typeof( { auto x = input.front.tupleof; }() ) ) )
{
static struct IterUntupled(R)
{
this(R input)
{
_input = input;
}
int opApply( int delegate( ref typeof(_input.front.tupleof) ) dg )
{
while( !_input.empty)
{
auto front = _input.front;
if ( auto result = dg(front.tupleof) )
return result;
_input.popFront();
}
return 0;
}
R _input;
}
return IterUntupled!R(input);
}
This will also unpack arbitrary structs and classes, is that too loose?
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list