Take exactly n element from range. Throws an exception if range has not enough elements.
Exception if range has less than n elements.
1 import std.exception : assertThrown; 2 import std.range : iota; 3 4 static assert(is(typeof(iota(10).takeExactly!5) == int[5])); 5 assert(iota(10).takeExactly!5 == [0, 1, 2, 3, 4]); 6 7 assertThrown!Exception(iota(2).takeExactly!5);
See Implementation
Take exactly n element from range. Throws an exception if range has not enough elements.