|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-02-12 10:38:03
----- Original Message -----
From: "rogeeff" <rogeeff_at_[hidden]>
> This error basicly means that iterator_aadaptor for some (magic)
> resons deduced that resulting value type is std::string const* while
> it should be std::string const.
Simplifying your error message, I see:
boost::iterator_adaptor<
// base
, personell_list::iterator
// policies
, boost::projection_iterator_policies<
pointer_to_unary_function<personnel_record const &, string const
&> >
, string const & // <- value
, string const * & // <- reference
, string const ** // <- pointer
, boost::detail::default_argument,boost::detail::default_argument>
So it looks really strange to me. make_projection_iterator just passes
value& as the reference parameter to iterator_adaptor. How (string const&)&
==> string const*& is beyond me. This part appears to be nothing more than a
compiler bug.
> Other compilers give me other errors. It seems that the root
> problem is that pointer_to_unary function incorrectly define
> result_type. While all others functors that returns reference (like
> identity, select1st,select2nd ) define result_type as T if operator()
> returns T const&, pointer_to_unary_function automatically propogate
> result type inherited from its argument, i.e. result_type is defined
> like T const&.
That's a known issue with some of the standard adaptors. We could adjust for
it by stripping the reference from the type, but unfortunately since you're
using MSVC that wouldn't help you.
> Could we use transforming type_traits here and define
> more smart ptr_fun or I just missing something?
I don't know what that means.
You can always declare the iterator_adaptor type yourself, explicitly:
typdef boost::iterator_adaptor<
personell_list::iterator
, boost::projection_iterator_policies<
pointer_to_unary_function<personnel_record const &, std::string
const &> >
std::string>
personell_name_iterator;
-Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk