Boost logo

Boost :

From: Arun Sivaramakrishnan (aruns_at_[hidden])
Date: 2001-01-21 00:16:51


The mail I send to John last night..
-arun
>
> ----- Original Message -----
> From: "John E. Potter" <jpotter_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Monday, January 01, 2001 7:14 AM
> Subject: Re: [boost] iterator_adaptors
>
> > This is a lack of documentation. Projection_iterator has reference
> > semantics always. There is a general problem with reference template
> > parameters. Vector<int&>? Set<int&>? They just don't work. But,
> >
> > struct RefFunc : public unary_function<SomeThing, int> {
> > int& operator() (SomeThing& st) { return st.someIntField; }
> > };
> >
> > works fine with both std::unary_function and projection_iterator. It
> > is a lie which works well. The only purpose of std::unary_function is
> > to extract the correct value_type. Reference and pointer are always
> > value_type& and value_type*. The function object must have reference
> > semantics.
> >
>
>
>
> Most often ,I wouldnt want to write a functor everytime I use
> transform_adaptor(or projection_adaptor)
> Now, when I try using transform/projection_adaptor in conjunction with
the
> binder1st,binder2nd etc ,type information is extracted in a manner
> that causes compiler errors.For example,the following wont compile.
>
> typedef boost::array<double,3> position3;
> typedef std::vector<position3>::iterator position_iter;
>
> void foo(position_iter first)
> {
> typedef boost::mem_fun1_ref_t<position3::reference
> ,position3,position3::size_type > mem_fun1_ref_t;
>
> typedef boost::binder2nd< mem_fun1_ref_t> Function;
> //////Function is a unary_function now with first_argument_ty =double&.
>
> typedef position3::reference/*this is double&*/
> (position3::*PFTYPE)(position3::size_type);
>
> typedef boost::projection_iterator<Function, position_iter,
> boost::iterator<std::random_access_iterator_tag, vtype>
> >::type coord_iterator;
>
> coord_iterator first(ibegin,
> Function(boost::mem_fun_ref((PFTYPE)&position3::operator[]),0)
> );
> //// etc
> }
>
> Regards,
> arun
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk