Skip to content

Commit

Permalink
Merge pull request orocos-toolchain#103 from orocos-toolchain/clang-b…
Browse files Browse the repository at this point in the history
…oost

boost lambda ist not working for boost 1.57 and clang 3.4, 3.5, 3.6, …
  • Loading branch information
Ruben Smits committed Jun 12, 2015
2 parents 26eb8aa + 20dadee commit ff33781
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ endif()

PROJECT(orocos-rtt)


SET( RTT_VERSION 2.8.0 )
STRING( REGEX MATCHALL "[0-9]+" RTT_VERSIONS ${RTT_VERSION} )
LIST( GET RTT_VERSIONS 0 RTT_VERSION_MAJOR)
Expand All @@ -42,6 +43,11 @@ if (NOT EXISTS ${PROJ_SOURCE_DIR}/orocos-rtt.cmake)
INCLUDE(${PROJ_SOURCE_DIR}/orocos-rtt.default.cmake)
endif ()

OPTION(USE_CPP11 "Turn on to replace boost::bind with cpp11 bind." OFF)
if(USE_CPP11)
ADD_DEFINITIONS(-DUSE_CPP11)
endif(USE_CPP11)

# On Windows, the default CMAKE_INSTALL_PREFIX is either:
# C:\Program Files\orocos-rtt or C:\Program Files (x86)\orocos-rtt
# However, we want it to be either:
Expand Down
6 changes: 6 additions & 0 deletions rtt/ExecutionEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@

#include <boost/bind.hpp>
#include <boost/ref.hpp>
#ifndef USE_CPP11
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#endif
#include <functional>
#include <algorithm>

Expand Down Expand Up @@ -180,7 +182,11 @@ namespace RTT
// Running: create message on stack.
RemoveMsg rmsg(f,this);
if ( this->process(&rmsg) )
#ifdef USE_CPP11
this->waitForMessages( ! bind(&ExecutableInterface::isLoaded, f) || bind(&RemoveMsg::found,boost::ref(rmsg)) );
#else
this->waitForMessages( ! lambda::bind(&ExecutableInterface::isLoaded, f) || lambda::bind(&RemoveMsg::found,boost::ref(rmsg)) );
#endif
if (!rmsg.found)
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions rtt/InputPort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ namespace RTT
{
FlowStatus result = NoData;
// read and iterate if necessary.
#ifdef USE_CPP11
cmanager.select_reader_channel( bind( &InputPort::do_read, this, boost::ref(sample), boost::ref(result), _1, _2), copy_old_data );
#else
cmanager.select_reader_channel( boost::bind( &InputPort::do_read, this, boost::ref(sample), boost::ref(result), boost::lambda::_1, boost::lambda::_2), copy_old_data );
#endif
return result;
}

Expand Down
12 changes: 12 additions & 0 deletions rtt/OutputPort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,15 @@ namespace RTT
has_initial_sample = true;
has_last_written_value = false;

#ifdef USE_CPP11
cmanager.delete_if( bind(
&OutputPort<T>::do_init, this, boost::ref(sample), _1)
);
#else
cmanager.delete_if( boost::bind(
&OutputPort<T>::do_init, this, boost::ref(sample), _1)
);
#endif
}

/**
Expand All @@ -252,9 +258,15 @@ namespace RTT
}
has_last_written_value = keeps_last_written_value;

#ifdef USE_CPP11
cmanager.delete_if( bind(
&OutputPort<T>::do_write, this, boost::ref(sample), _1)
);
#else
cmanager.delete_if( boost::bind(
&OutputPort<T>::do_write, this, boost::ref(sample), boost::lambda::_1)
);
#endif
}

void write(base::DataSourceBase::shared_ptr source)
Expand Down
2 changes: 2 additions & 0 deletions rtt/internal/ConnectionManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
#include <boost/tuple/tuple.hpp>
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#ifndef USE_CPP11
#include <boost/lambda/lambda.hpp>
#endif

#include <rtt/os/Mutex.hpp>
#include <rtt/os/MutexLock.hpp>
Expand Down
11 changes: 11 additions & 0 deletions rtt/internal/OperationInterfacePartFused.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
#include <boost/fusion/include/make_unfused_generic.hpp>
#endif

#ifndef USE_CPP11
#include <boost/lambda/lambda.hpp>
#endif

#include <vector>
#include <string>
Expand Down Expand Up @@ -214,12 +216,21 @@ namespace RTT
if ( args.size() != OperationInterfacePartFused<Signature>::arity() ) throw wrong_number_of_args_exception(OperationInterfacePartFused<Signature>::arity(), args.size() );
// note: in boost 1.41.0+ the function make_unfused() is available.
#if BOOST_VERSION >= 104100
#ifdef USE_CPP11
return this->op->signals( boost::fusion::make_unfused(boost::bind(&FusedMSignal<Signature>::invoke,
boost::make_shared<FusedMSignal<Signature> >(func, SequenceFactory::assignable(args.begin()), subscriber),
_1
)
)
);
#else
return this->op->signals( boost::fusion::make_unfused(boost::bind(&FusedMSignal<Signature>::invoke,
boost::make_shared<FusedMSignal<Signature> >(func, SequenceFactory::assignable(args.begin()), subscriber),
boost::lambda::_1
)
)
);
#endif
#else
return this->op->signals( boost::fusion::make_unfused_generic(boost::bind(&FusedMSignal<Signature>::invoke,
boost::make_shared<FusedMSignal<Signature> >(func, SequenceFactory::assignable(args.begin()),subscriber),
Expand Down
7 changes: 7 additions & 0 deletions rtt/internal/signal_template.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@
#include "NA.hpp"

#ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE
#ifndef USE_CPP11
#include <boost/lambda/bind.hpp>
#include <boost/bind.hpp>
#include <boost/lambda/casts.hpp>
#endif
#else
#include "../os/MutexLock.hpp"
#endif
Expand Down Expand Up @@ -138,9 +140,14 @@ namespace RTT {
// this code did initially not work under gcc 4.0/ubuntu breezy.
// connection_t::get() const becomes an undefined symbol.
// works under gcc 3.4
#ifdef USE_CPP11
mconnections.apply( bind(&connection_impl::emit,
bind( &applyEmit, _1) // works for any compiler
#else
mconnections.apply( boost::lambda::bind(&connection_impl::emit,
boost::lambda::bind( &applyEmit, boost::lambda::_1) // works for any compiler
//not in gcc 4.0.2: boost::lambda::ll_static_cast<connection_impl*>(boost::lambda::bind(&connection_t::get, boost::lambda::_1))
#endif
#if OROCOS_SIGNATURE_NUM_ARGS != 0
,OROCOS_SIGNATURE_ARGS
#endif
Expand Down

0 comments on commit ff33781

Please sign in to comment.