Boost logo

Boost :

From: Maxim Yegorushkin (e-maxim_at_[hidden])
Date: 2004-03-19 21:50:13

Hi guys.

I encountered a pitfall when trying to use boost::lambda for dereferencing a smart pointer. Current lambda implementation assumes that operator*() can be applied to either a plain pointer or an iterator. That leads to an error message when applying the operator to a smart pointer complaining about std::iterator_traits<> not being specialized for the smart pointer.

Consider the code:

struct some
     void foo(int);

boost::shared_ptr<some> ptr(new some);

     , *lm::_1
     , 0

the bind expression won’t compile until we hack std::iterator_traits<boost::shared_ptr<> >:

template<class T>
struct std::iterator_traits<boost::shared_ptr<T> > : std::iterator<void, T>

My point is: why don’t add an additional level of indirection for boost::lambda::detail::contentsof_type<> so that the indirection will allow the user to specialize it for smart pointers?

Maxim Yegorushkin
MetaCommunications Engineering

Boost list run by bdawes at, gregod at, cpdaniel at, john at