With Boost.Foreach, you pretty much get stuck with a reference to a dereferenced iterator, since this is what Boost.Foreach was designed to: simplify access to elements in a range. However, if you are looking for only one element that matches the criteria, you can try std::find_if() :
struct criteria { template <class T> bool operator()(T const & element) const { return (element )? true : false; } };
It also looks like you want to apply operations across the entire list, in which case I suggest using something like std::min_element() or std::max_element() along with Boost.Iterators, like boost::transform_iterator .
struct transformation { typedef int result_type; template <class T> int operator()(T const & element) const {
source share