Raise any_range against "canonical form" - what's the last?

Boost any_range documentation reads as follows:

Despite the fact that the basic any_iteratorversion is the fastest version, the performance overhead is any_rangestill noticeable due to the cost of virtual function calls needed to implement increment, decrease, advance, equal, etc. Often the best design choice is to convert to canonical form .

What does the author mean by "canonical form"? Can someone give an example?

EDIT: As I said here, I asked the same question on the mailing list for accelerated users. Here is what Neil Groves, the original author of this text, said:

For example, copying a range to a vector.

Yes, this is exactly the alternative design that I had in mind when writing the documentation. The overhead for iterating over any_range is quite significant and often poorly compared to copying a particular type of result into a container, such as a vector. However, this is not always the case, and some Boost.Range users wanted to implement algorithms that work with any_range instances. Sometimes it may be desirable to allow, for example, the identification of algorithms from a common library that supports various containers. Using any_range can also make sense when the number of passes in the range is small, but the memory size of the base container is very large.

. , any_range. , , . .

+5
2

, std::vector .

, , any_range. , , , , .

+3

any_range , , , . Pimpl .

, ( ) .

+3

All Articles