Opened 15 years ago

Closed 14 years ago

Last modified 13 years ago

#1756 closed Patches (wontfix)

Proposal to add make_view iterator range generator

Reported by: andysem@… Owned by: Thorsten Ottosen
Milestone: Boost 1.36.0 Component: range
Version: Boost Development Trunk Severity: Not Applicable
Keywords: range, view, transform_iterator Cc:

Description

I propose to add a simple helper function to create an iterator range of boost::transform_iterators. This would effectively create a view over a different range or a container.

Currently this is possible to do with considerable code duplication:

make_iterator_range(

make_transform_iterator(vec.begin(), fun), make_transform_iterator(vec.end(), fun));

Here "fun" could be a rather complex lambda or bind expression. What I propose is to wrap these calls into a simple generator make_view. The above code would look much better:

make_view(vec.begin(), vec.end(), fun);

or

make_view(vec, fun);

I've attached a sample implementation of the make_view function.

PS: This straightforward implementation is quite sufficient for me and, IMHO, for most cases. However, one might want to optimize it by storing only one copy of the function object in the view or even deriving the view from it to make use of EBO. This imply that transform_iterator would have to be replaced with another equivalent that does not store the function object internally.

Attachments (1)

view.hpp (937 bytes ) - added by andysem@… 15 years ago.
Sample implementation of the make_view function

Download all attachments as: .zip

Change History (3)

by andysem@…, 15 years ago

Attachment: view.hpp added

Sample implementation of the make_view function

comment:1 by Thorsten Ottosen, 14 years ago

Resolution: wontfix
Status: newclosed

Your code is quite fine, but this really belongs in the range_ex library which is up for review soon.

comment:2 by cheap Cialis buy, 13 years ago

Snake: Huh? Oh, right. See you two a little bit laters-s-s. Ace: They'll be back. With pizza! erezione fioricet free prescription best price cialis tjtoo9q tramadol org

Note: See TracTickets for help on using tickets.