|
Boost : |
From: Arun Sivaramakrishnan (aruns_at_[hidden])
Date: 2001-03-29 23:13:38
How about storing a pointer or a scoped_ptr to the AdaptableUnaryFunction
intialized to NULL in the default constructor of
transform_iterator_policies
and intialized to a valid one in its other constructor,
ie
template <class AdaptableUnaryFunction>
struct transform_iterator_policies : public default_iterator_policies
{
transform_iterator_policies() { }
transform_iterator_policies(const AdaptableUnaryFunction& f)
: m_pf(new AdaptableUnaryFunction(f)) { }
template <class Reference, class Iterator>
Reference dereference(type<Reference>, const Iterator& iter) const
{ return *m_pf(*iter); }
scoped_ptr<AdaptableUnaryFunction> m_pf;
};
----- Original Message -----
From: "Jeremy Siek" <jsiek_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, March 29, 2001 9:43 PM
Subject: std::binder1st and transform_iterator (was Re: [boost] iterator
adaptors & concept checks)
> Hi Kresimir,
>
> What a bummer, it looks like we can't legally use std::binder1st with
> transform_iterator. The requirement for default constructor is not
> accidental, it is absolutely required because the function object needs to
> be contained in the iterator, and the standard requires iterators to have
> default constructors. We'll have to use a replacement for binder1st in the
> example.
>
> Perhaps the lack of default constructor in std::binder1st qualifies as a
> DR?
>
> Cheers,
> Jeremy
>
>
> On Sat, 17 Mar 2001 fresl_at_[hidden] wrote:
> fresl>
> fresl> It seems impossible to compile
> fresl> `transform_iterator_example.cpp'
> fresl> either with g++ (one of the latest snapshots from
> fresl> `http://www.codesourcery.com/gcc-snapshots.html',
> fresl> with its own library) or Comeau's compiler `como'
> fresl> (with its library) because:
> fresl>
> fresl> "/home/krcko/include/boost/iterator_adaptors.hpp",
> fresl> line 832: error: no default constructor exists for class
> fresl> "std::binder1st<std::plus<int>>"
> fresl> transform_iterator_policies() { }
> fresl>
> fresl> It is possible to cheat and add default constructor to
> fresl> `std::binder1st<>' (and to `binder2nd<>' and to ...),
> fresl> but I wonder what standard says about default-construct-
> fresl> ability of these functors.
> fresl>
> fresl>
> fresl> Sincerely,
> fresl>
> fresl> Kresimir Fresl
>
>
> ----------------------------------------------------------------------
> Jeremy Siek www: http://www.lsc.nd.edu/~jsiek/
> Ph.D. Candidate email: jsiek_at_[hidden]
> Univ. of Notre Dame work phone: (219) 631-3906
> ----------------------------------------------------------------------
>
>
>
> To unsubscribe, send email to: <mailto:boost-unsubscribe_at_[hidden]>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk