[Home]Suggestions - Utility Library

BOOST WIKI | RecentChanges | Preferences | Page List | Links List

This page is for suggestions for improvements to the Boost Utility Library.

Back to utility library pages


for_all()

I find it tedious to write out things like

    for_each(container.begin(), container.end(), whatever...);

Not only does it take alot of typing, but it is also error-prone -- e.g. you might change the first "container" to "container2", but forget to change the second one.

There should be a standard for_all(), with definition something like this (demonstration only):

    template <typename C, typename F> void for_all(C& vec, const F& func) {
        for_each(vec.begin(), vec.end(), func);
    }

    - Chuck

There is a library in the Boost Sandbox that overloads all standard algorithms for containers instead of iterator pairs. I am also looking at making a more formal definition of a 'range' concept for a pair of iterators that would not only be used for the algorithms, but would make some iterator adaptors easier to use (eg filter_iterator) and make useful return values from functions.

I don't believe an algorithm with a different name is required.

AlisdairM?


BOOST WIKI | RecentChanges | Preferences | Page List | Links List
Edit text of this page | View other revisions
Last edited May 21, 2003 2:35 am (diff)
Search:
Disclaimer: This site not officially maintained by Boost Developers