iota result as member variable
Alex via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Mar 23 23:54:25 PDT 2016
Hi everybody,
doing some optimization on my code, I faced some strange question:
how to save a iota result in a class member?
Say I have
class A
{
??? member;
auto testIter4()
{
return iota(0,5);
}
}
void main()
{
A a = new A();
a.member = testIter4();
}
how would I declare the member?
What I found till now is this:
http://comments.gmane.org/gmane.comp.lang.d.learn/60129
where it is said, that I could use
inputRangeObject(testIter4)
and declare my member as InputRange!int
But then the random access is gone and, furthermore, looking into
the source of std/range/interfaces.d found some lines (about line
nr. 110) about performance and that the InputRangeObject has a
performance penalty of about 3 times over using the iota struct
directly. So, I could declare my member as typeof(iota(0))
Did I miss something?
More information about the Digitalmars-d-learn
mailing list