iterator_adaptor problem (mpl?)

Consider a container such as
std::vector

Angus Leeming
Why struggle?
boost::transform_iterator should give you just what you need:
struct select1st
{
template <class P>
P::first_type& operator()(P& pair) { return pair.first; }
template <class P>
P::first_type const& operator()(P const& pair) { return pair.first; }
};
namespace boost
{
template <class T>
struct result_of
Try plain mpl::if_. apply_if invokes one of two nullary metafunctions, but a (const) int& is not a metafunction.
Nope:
template
Any pointers? I attach the code as I have it.
While I'm at it, is there not something in the MPL that will return the appropriate const-qualified reference for me?
What do you mean?
None of the header file names in boost/mpl jump out and grab me, but I may well be looking in the wrong place.
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com

David Abrahams wrote:
Why struggle?
boost::transform_iterator should give you just what you need:
Many thanks, David. That's altogether much nicer. However, result_of is not part of boost 1.31. Attached is an implementation of my code that works fine with 1.31. Unfortunately, I can't create a 'const_first_iterator' from a 'first_iterator'. Ie, I need: store my_store; store const & my_const_store = my_store; // UGLY! store::const_first_iterator const begin = my_const_store.begin_first(); store::const_first_iterator const end = my_const_store.end_first(); Any further clues, or is this as far as I can go this way? Angus

Angus Leeming
See the converting constructor described at http://tinyurl.com/229ld#transform-iterator-synopsis. As long as the underlying iterators and unaryfunctions are convertible, the initialization should work just fine.
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com
participants (2)
-
Angus Leeming
-
David Abrahams