|
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::bind(
&some::foo
, *lm::_1
, 0
)
)
(ptr);
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 http://www.meta-comm.com/engineering/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk