Skip to main content Link Search Menu Expand Document (external link)

Forward Range

Question

In the report function, the range.take(5) expression consumes 5 elements. Why isn’t this visibible in the second invokation of report in the main function? Hint: take a look at the signature of take

range is a struct and is therefore passed by copy to take

Correct!

Since save is defined on FibonacciSeries, it is automaticallly called whenever an argument is passed

save is never called automatically

range is const so modifications on it are discarded

Modifications of const objects is signaled at compile time. Since the program compiles succesfully, const is not the problem.

report receives a copy of range

report specifically receives a reference to range