0

Consider this template member method of some class:

template<typename T>
bool elementIsInSharedPtrVector(const T& p_elem, const std::vector< boost::shared_ptr< T > >& p_Vector) const
{
    return (std::find_if(p_Vector.begin(), p_Vector.end(), **boost::lambda::_1 == p_elem) != p_Vector.end());
}

The compiler gives this error(besides hundreds of template errors):

usr/include/boost/pointee.hpp:30: error: no type named 'element_type' in 'struct SLnAdjW'

The type SLnAdjW is a POD C struct with a free defined == operator function.

What I'm doing wrong here?

Juergen
  • 3,489
  • 6
  • 35
  • 59
  • 1
    This might be largely irrelevant, but find_if returns an iterator and your function returns a bool - that may add to the noise – doctorlove Sep 10 '13 at 12:46
  • 1
    Why do you have `**boost::lambda::_1` shouldn't it just be `*boost::lambda::_1` ? – user71404 Sep 10 '13 at 13:21
  • 2
    Is there a reason you're de-referencing _1 twice? The predicate to find_if doesn't take iterators, it takes the underlying value type, in this case boost::shared_pointers. – bstamour Sep 10 '13 at 13:21
  • Thank you guys! I assumed iterators instead of value types. De-referencing only once is compile clean. – Juergen Sep 10 '13 at 13:34

0 Answers0