Boost logo

Boost Users :

Subject: [Boost-users] Compilation error Boost lambda function (Boost 1.40)
From: Joost Kraaijeveld (J.Kraaijeveld_at_[hidden])
Date: 2009-12-13 10:57:19


Hi,

What is wrong in my syntax in the std::for_each call (the BOOST_FOREACH works fine):

...
class Session
{
        virtual void stopSession();
}

class ServerSession : public Sessoon
{
}

typedef std::map<unsigned long, ServerSession*> ServerSessions;
ServerSessions serverSessions;
...

...
typedef std::pair<unsigned long, ServerSession*> ServerSessionsIterator;
BOOST_FOREACH(ServerSessionsIterator session,serverSessions)
{
        session.second->stopSession();
}

std::for_each( serverSessions.begin(),
                      serverSessions.end(),
                      boost::lambda::bind( &ServerSession::stopSession, // function
                                           boost::bind(&ServerSessions::value_type::second, boost::lambda::_1))); // object

The actual error is:

make -k -j6 all
/bin/bash ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I/home/jkr/Programming/C++/Dagda/library/DagdaCom -I../../include/Dagda/DagdaConfig -DDEVELOPMENT -DDANUEXE=1 -I/home/jkr/Programming/C++/Danu/include/Danu -DDAGDADLL=1 -I /home/jkr/Programming/C++/Dagda/library/../include/Dagda -pipe -Wall -Wextra -Wundef -Wshadow -Wconversion -I/usr/include -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -g -O2 -MT libdagdacom_la-Server.lo -MD -MP -MF .deps/libdagdacom_la-Server.Tpo -c -o libdagdacom_la-Server.lo `test -f 'Server.cpp' || echo '/home/jkr/Programming/C++/Dagda/library/DagdaCom/'`Server.cpp
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I/home/jkr/Programming/C++/Dagda/library/DagdaCom -I../../include/Dagda/DagdaConfig -DDEVELOPMENT -DDANUEXE=1 -I/home/jkr/Programming/C++/Danu/include/Danu -DDAGDADLL=1 -I /home/jkr/Programming/C++/Dagda/library/../include/Dagda -pipe -Wall -Wextra -Wundef -Wshadow -Wconversion -I/usr/include -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -g -O2 -MT libdagdacom_la-Server.lo -MD -MP -MF .deps/libdagdacom_la-Server.Tpo -c /home/jkr/Programming/C++/Dagda/library/DagdaCom/Server.cpp -fPIC -DPIC -o .libs/libdagdacom_la-Server.o
/usr/include/boost/lambda/detail/actions.hpp: In static member function ‘static RET boost::lambda::function_action<2, T>::apply(A1&, A2&) [with RET = void, A1 = void (DagdaCom::Session::* const)(), A2 = const boost::_bi::bind_t<DagdaCom::ServerSession* const&, boost::_mfi::dm<DagdaCom::ServerSession*, std::pair<const long unsigned int, DagdaCom::ServerSession*> >, boost::_bi::list1<boost::arg<1> > >, T = boost::lambda::detail::unspecified]’:
/usr/include/boost/lambda/detail/lambda_functor_base.hpp:418: instantiated from ‘RET boost::lambda::lambda_functor_base<boost::lambda::action<2, Act>, Args>::call(A&, B&, C&, Env&) const [with RET = void, A = std::pair<const long unsigned int, DagdaCom::ServerSession*>, B = const boost::tuples::null_type, C = const boost::tuples::null_type, Env = const boost::tuples::null_type, Act = boost::lambda::function_action<2, boost::lambda::detail::unspecified>, Args = boost::tuples::tuple<void (DagdaCom::Session::* const)(), const boost::_bi::bind_t<DagdaCom::ServerSession* const&, boost::_mfi::dm<DagdaCom::ServerSession*, std::pair<const long unsigned int, DagdaCom::ServerSession*> >, boost::_bi::list1<boost::arg<1> > >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>]’
/usr/include/boost/lambda/detail/lambda_functors.hpp:175: instantiated from ‘typename T::sig<boost::tuples::tuple<A&, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >::type boost::lambda::lambda_functor<Base>::operator()(A&) const [with A = std::pair<const long unsigned int, DagdaCom::ServerSession*>, T = boost::lambda::lambda_functor_base<boost::lambda::action<2, boost::lambda::function_action<2, boost::lambda::detail::unspecified> >, boost::tuples::tuple<void (DagdaCom::Session::* const)(), const boost::_bi::bind_t<DagdaCom::ServerSession* const&, boost::_mfi::dm<DagdaCom::ServerSession*, std::pair<const long unsigned int, DagdaCom::ServerSession*> >, boost::_bi::list1<boost::arg<1> > >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >]’
/usr/include/c++/4.3/bits/stl_algo.h:3791: instantiated from ‘_Funct std::for_each(_IIter, _IIter, _Funct) [with _IIter = std::_Rb_tree_iterator<std::pair<const long unsigned int, DagdaCom::ServerSession*> >, _Funct = boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::action<2, boost::lambda::function_action<2, boost::lambda::detail::unspecified> >, boost::tuples::tuple<void (DagdaCom::Session::* const)(), const boost::_bi::bind_t<DagdaCom::ServerSession* const&, boost::_mfi::dm<DagdaCom::ServerSession*, std::pair<const long unsigned int, DagdaCom::ServerSession*> >, boost::_bi::list1<boost::arg<1> > >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >]’
/home/jkr/Programming/C++/Dagda/library/DagdaCom/Server.cpp:204: instantiated from here
/usr/include/boost/lambda/detail/actions.hpp:87: error: no matching function for call to ‘boost::lambda::function_adaptor<void (DagdaCom::Session::*)()>::apply(void (DagdaCom::Session::* const&)(), const boost::_bi::bind_t<DagdaCom::ServerSession* const&, boost::_mfi::dm<DagdaCom::ServerSession*, std::pair<const long unsigned int, DagdaCom::ServerSession*> >, boost::_bi::list1<boost::arg<1> > >&)’
/usr/include/boost/lambda/detail/actions.hpp:87: error: return-statement with a value, in function returning 'void'
make: *** [libdagdacom_la-Server.lo] Error 1
make: Target `all' not remade because of errors.

TIA

-- 
Groeten,
Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
web: www.askesis.nl

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net