Skip to content

Instantly share code, notes, and snippets.

@k3kaimu
Forked from majiang/map.d
Last active December 17, 2015 08:58
Show Gist options
  • Save k3kaimu/5583476 to your computer and use it in GitHub Desktop.
Save k3kaimu/5583476 to your computer and use it in GitHub Desktop.
コンパイルしてないので動くかどうか不明
module map;
auto map(FT, ATR)(FT f, ATR x)
if(isInputRange!ATR && is(typeof(f(x.front))) && !is(typeof(f(x.front)) == void))
{
static struct R
{
auto front()
{
return f(x.front);
}
void popFront()
{
x.popFront;
}
bool empty()
{
return x.empty();
}
private:
FT _f;
ART _x;
}
return R(f, x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment