View source code
Display the source code in std/range/package.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.
take, but assumes that
range has at least
n elements. Consequently, the result of
always defines the
length property (and initializes it to
range itself does not define
auto takeExactly(R) (
The result of
takeExactly is identical to that of
cases where the original range defines
length or is infinite.
take, however, it is illegal to pass a range with less than
n elements to
takeExactly; this will cause an assertion failure.
.algorithm .comparison : equal; auto a = [ 1, 2, 3, 4, 5 ]; auto b = takeExactly(a, 3); assert(equal(b, [1, 2, 3])); static assert(is(typeof(b .length) == size_t)); writeln(b .length); // 3 writeln(b .front); // 1 writeln(b .back); // 3
Andrei Alexandrescu, David Simcha, Jonathan M Davis, and Jack Stouffer. Credit for some of the ideas in building this module goes to Leonardo Maffi.
Copyright © 1999-2023 by the D Language Foundation | Page generated by ddox.