boost::adaptors::keys for mutable ranges of pairs

Hello, map.hpp defines two overloads for adaptors::values, one for StdPairRange& and another for const StdPairRange const& rng. On the other hand, there is just a single adaptors::keys which takes StdPairRange const&. In particular, the code below will not compile: boost::find_if( boost::adaptors::keys(rng), SomePredicate() ).base()->second=NewValue(); Therefore, I would propose an adaptors::keys(StdPairRange& rng) overload similar to adaptors::values(StdPairRange&). Iterators of the returned range shall have a mutable base iterator. Further, iterators of the returned range should have a reference type of range_value<StdPairRange>::type::first_type& , so the elements in keys are mutable where StdPairRange admits this. Regards, Valentin -- Valentin Ziegler | vziegler@think-cell.com Software Engineer think-cell Software GmbH | Chausseestr. 8/E | 10115 Berlin | Germany http://www.think-cell.com | phone +49 30 666473-10 | US phone +1 800 891 8091 Amtsgericht Berlin-Charlottenburg, HRB 85229 | European Union VAT Id DE813474306 Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl

P-Stade Oven range library provides many useful range adaptors. For your use case, you can use more generic `pstade::oven::elements_c<N>` range range adaptor (or `pstade::oven::make_elements_c<N>`) *boost::find_if(rng | pstade::oven::elements_c<0>(), pred) = val; *boost::find_if(pstade::oven::make_elements_c<0>(rng), pred) = val; Here is the documentation: http://p-stade.sourceforge.net/oven/doc/html/oven/range_adaptors.html#oven.r... See also: http://p-stade.sourceforge.net/oven/doc/html/oven/range_adaptors.html#oven.r... If you use clang and libc++, you might have a compile error due to the incompatibility between the forward declaration and the inline namespace. In that case, you can fix the problem by removing the forward declaration of `std::pair` and adding `#include <utility>` in pstade/apple/pair_fwd.hpp. Regards, Michel
participants (2)
-
Michel Morin
-
Valentin Ziegler