Let's say I want to write a simple function keys
that takes in a std::map
and returns an iterator_range
that provides the keys of the map. How would I do it?
template<typename A, typename B>
Range<A> keys(const std::map<A, B> & m) { ??? }
I want to apply the same pattern to various other containers, but I think this is a good prototypical example.
Edit: I'm guessing I need something in the realm of Boost's range_adapter
s and/or transform_iterator
s but I'm not familiar enough with them to apply them here.