
This code: #include <iostream> #include <algorithm> #include <boost/tr1/functional.hpp> using std::ostream; class Value { public: Value() : m_amount(0) {} void IncreaseBy(int amount) { m_amount += amount; } void WriteTo(ostream& stream) const { stream << m_amount; } private: int m_amount; }; ostream& operator <<(ostream& stream, const Value& value) { value.WriteTo(stream); return stream; } int main() { Value sum; int values[] = { 1, 2, 3, 4, 5 }; std::for_each(values, values + 5, std::tr1::bind(&Value::IncreaseBy, sum)); std::cout << "The value is " << sum << std::endl; return 0; } Produces compile error output like the following when compiled on Fedora 10 (Intel): In file included from /usr/include/boost/tr1/functional.hpp:8, from ValueSum.cpp:3: /usr/include/boost/tr1/detail/config.hpp:60:26: error: no include path in which to search for utility /usr/include/boost/mem_fn.hpp: In member function ‘R& boost::_mfi::dm<R, T>::operator()(T&) const [with R = void ()(int), T = Value]’: /usr/include/boost/bind.hpp:221: instantiated from ‘R boost::_bi::list1<A1>::operator()(boost::_bi::type<R>, F&, A&, long int) [with R = void (&)(int), F = boost::_mfi::dm<void ()(int), Value>, A = boost::_bi::list1<int&>, A1 = boost::_bi::value<Value>]’ /usr/include/boost/bind/bind_template.hpp:32: instantiated from ‘typename boost::_bi::result_traits<R, F>::type boost::_bi::bind_t<R, F, L>::operator()(A1&) [with A1 = int, R = void (&)(int), F = boost::_mfi::dm<void ()(int), Value>, L = boost::_bi::list1<boost::_bi::value<Value> >]’ /usr/lib/gcc/i386-redhat-linux/4.3.2/../../../../include/c++/4.3.2/bits/stl_algo.h:3791: instantiated from ‘_Funct std::for_each(_IIter, _IIter, _Funct) [with _IIter = int*, _Funct = boost::_bi::bind_t<void (&)(int), boost::_mfi::dm<void ()(int), Value>, boost::_bi::list1<boost::_bi::value<Value> > >]’ ValueSum.cpp:31: instantiated from here /usr/include/boost/mem_fn.hpp:359: error: invalid use of non-static member function What is needed for the code to compile and run properly?