[C++-sig] Re: map key

David Abrahams dave at boost-consulting.com
Sat Jan 18 01:24:14 CET 2003


David Abrahams <dave at boost-consulting.com> writes:

> "Mike Rovner" <mike at bindkey.com> writes:
>
>> But while it's great at hand-maid keys() and items() lists, there's
>> still a problem with iterator<map<const Key*, Value> >(). Obviosly
>> it doesn't know about ptr().
>
> I think it doesn't know about std::pair<const Key*,Value>, which is
> the iterator's value type ;-)
>
> A Python map's iterator just iterates the keys, so you might need to
> build the iterator by hand if you want it to do the same thing.

You could use the Boost transform iterator adaptor with std::select1st
to build an iterator over keys and expose it with class_<...>.range().

-- 
                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution





More information about the Cplusplus-sig mailing list