
On 12/13/05, Peter Dimov <pdimov@mmltd.net> wrote:
Are you sure that you want this, even if it did compile? If you apply remove_if+transform_iterator on:
A, 2 B, 3 C, 4 D, 15 E, 16 F, 17
you'll get
A, 15 B, 16 C, 17 D, -- E, -- F, --
where -- denotes an unspeficied value.
I was not aware of this. Thanks for pointing out.
If this is the desired result, try
struct to_num { typedef int & result_type;
int & operator()(std::pair<std::string, int>& p) const { return p.second; } };
If, on the other hand, you want
D, 15 E, 16 F, 17 --, -- --, -- --, --
you don't need transform_iterator at all:
std::remove_if( c.begin(), c.end(),
boost::bind( std::less_equal<int>(), boost::bind( to_num(), _1 ), 10 )
);
Thanks. I'm already using this way. I was just wondering if it was possible to use transform_iterator and avoid the functor. Regards, Josue Gomes