Boost logo

Boost Users :

Subject: Re: [Boost-users] [iterator] transform_iterator
From: Max (loadcom_at_[hidden])
Date: 2008-12-24 21:18:12


But another minor thing that I don't understand is why
the template parameters of the transform_iterator and
the parameters of its constructor are in the different
order.

If I were the author, I would feel keeping them in the
same order be more natural and more straightforward.

Perhaps letting Function be the 1st template parameter make
it clearer the behavior of the class? :-)

If this is a too stupid question, just ignore. :-)

Thanks.

B/Rgds
Max

----- Original Message -----
From: Steven Watanabe
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] [iterator] transform_iterator
Date: 2008-12-25 00:47:36

AMDG

Max wrote:

> I just came across transform_iterator and found it a useful generic tool.
> But is it possible for it to go further to make the following code get
> compiled and run as expected?
>

No.

> struct A
> {
> int i_;
> A() : i_(0) {}
> explicit A(int i) : i_(i) {}
> };
>
> const int N = 5;
> A a_list[N] = { A(-3), A(1), A(3), A(2), A(-4) };
>
> typedef boost::function fn_t;
>
> // sorting a_list according to the elements' i_ member
> std::stable_sort(boost::make_transform_iterator(a_list, fn_t(boost::bind(&A::i_, _1))),
> boost::make_transform_iterator(a_list+N, fn_t(boost::bind(&A::i_, _1))),
> std::less());
>

stable_sort assumes that the sort keys are the same as the objects
that it is moving around.

In Christ,
Steven Watanabe


-------------------------------------------------------------------
ÐÂÀ˿ռ䡪¡ªÓëÅóÓÑ¿ªÐÄ·ÖÏíÍøÂçÐÂÉú»î£¡(http://space.sina.com.cn/ )

-------------------------------------------------------------------
ÐÂÀ˿ռ䡪¡ªÓëÅóÓÑ¿ªÐÄ·ÖÏíÍøÂçÐÂÉú»î£¡(http://space.sina.com.cn/ )


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net