Replace boost::bind by std::bind and lambda function

This commit is contained in:
gallaert 2020-04-20 19:47:28 +01:00 committed by James Turner
parent b13d7f9392
commit 2ff6a4966a
13 changed files with 94 additions and 116 deletions

View File

@ -29,7 +29,6 @@
#include <osg/BoundingBox>
#include <osg/MatrixTransform>
#include <boost/bind.hpp>
#include <boost/function.hpp>
namespace osg
@ -345,13 +344,10 @@ namespace canvas
if( style->func )
style = style->next = new StyleSetter;
style->func = boost::bind
(
&type_match<Derived>::call,
_1,
_2,
bindStyleSetter<T1>(name, setter)
);
style->func = std::bind(&type_match<Derived>::call,
std::placeholders::_1,
std::placeholders::_2,
bindStyleSetter<T1>(name, setter));
return *style;
}
@ -528,7 +524,9 @@ namespace canvas
boost::function<void (Derived&, T)>
bindOther( void (Other::*setter)(T), OtherRef Derived::*instance_ref )
{
return boost::bind(setter, boost::bind(instance_ref, _1), _2);
return std::bind(setter,
std::bind(instance_ref, std::placeholders::_1),
std::placeholders::_2);
}
template<typename T, class Derived, class Other, class OtherRef>
@ -537,16 +535,10 @@ namespace canvas
bindOther( const boost::function<void (Other&, T)>& setter,
OtherRef Derived::*instance_ref )
{
return boost::bind
(
setter,
boost::bind
(
&reference_from_pointer<Other, OtherRef>,
boost::bind(instance_ref, _1)
),
_2
);
return std::bind(setter,
std::bind(&reference_from_pointer<Other, OtherRef>,
std::bind(instance_ref, std::placeholders::_1)),
std::placeholders::_2);
}
template<typename T1, typename T2, class Derived>
@ -555,14 +547,11 @@ namespace canvas
bindStyleSetter( const std::string& name,
const boost::function<void (Derived&, T2)>& setter )
{
return boost::bind
(
setter,
// We will only call setters with Derived instances, so we can safely
// cast here.
boost::bind(&derived_cast<Derived>, _1),
boost::bind(&getValue<T1>, _2)
);
return std::bind(setter,
// We will only call setters with Derived instances, so we can safely
// cast here.
std::bind(&derived_cast<Derived>, std::placeholders::_1),
std::bind(&getValue<T1>, std::placeholders::_2));
}
bool isStyleEmpty(const SGPropertyNode* child) const;

View File

@ -28,8 +28,6 @@
#include <simgear/structure/SGSharedPtr.hxx>
#include <simgear/math/sg_types.hxx>
#include <boost/bind.hpp>
class SGPropertyNode;
namespace simgear
@ -82,7 +80,7 @@ public:
template<class C>
Request* done(C* instance, void (C::*mem_func)(Request*))
{
return done(boost::bind(mem_func, instance, _1));
return done(std::bind(mem_func, instance, std::placeholders::_1));
}
/**
@ -97,7 +95,7 @@ public:
template<class C>
Request* fail(C* instance, void (C::*mem_func)(Request*))
{
return fail(boost::bind(mem_func, instance, _1));
return fail(std::bind(mem_func, instance, std::placeholders::_1));
}
/**
@ -112,7 +110,7 @@ public:
template<class C>
Request* always(C* instance, void (C::*mem_func)(Request*))
{
return always(boost::bind(mem_func, instance, _1));
return always(std::bind(mem_func, instance, std::placeholders::_1));
}
/**

View File

@ -29,7 +29,6 @@
#include <simgear/structure/SGWeakReferenced.hxx>
#include <simgear/structure/SGWeakPtr.hxx>
#include <boost/bind.hpp>
#include <boost/call_traits.hpp>
#include <boost/function.hpp>
#include <boost/mpl/has_xxx.hpp>
@ -217,7 +216,7 @@ namespace nasal
* .member("x_writeonly", &MyClass::setX)
* // Methods can be nearly anything callable and accepting a reference
* // to an instance of the class type. (member functions, free functions
* // and anything else bindable using boost::function and boost::bind)
* // and anything else bindable using boost::function and std::bind)
* .method("myMember", &MyClass::myMember)
* .method("doSomething", &MyClass::doSomethingElse)
* .method("other", &myOtherFreeMember);
@ -596,9 +595,12 @@ namespace nasal
const std::string&,
Param& )>& getter )
{
return _get(boost::bind(
convert_param_invoker<Param>, getter, _1, _2, _3, _4
));
return _get(std::bind(convert_param_invoker<Param>,
getter,
std::placeholders::_1,
std::placeholders::_2,
std::placeholders::_3,
std::placeholders::_4));
}
/**
@ -672,12 +674,12 @@ namespace nasal
// naContext,
// const std::string&,
// naRef )
return _set(boost::bind(
setter,
_1,
_3,
boost::bind(from_nasal_ptr<Param>::get(), _2, _4)
));
return _set(std::bind(setter,
std::placeholders::_1,
std::placeholders::_3,
std::bind(from_nasal_ptr<Param>::get(),
std::placeholders::_2,
std::placeholders::_4)));
}
/**
@ -769,7 +771,10 @@ namespace nasal
const boost::function<Ret (raw_type&, const CallContext&)>& func
)
{
return method(name, boost::bind(method_invoker<Ret>, func, _1, _2));
return method(name, std::bind(method_invoker<Ret>,
func,
std::placeholders::_1,
std::placeholders::_2));
}
/**
@ -783,16 +788,13 @@ namespace nasal
const method_variadic_t<Ret, Args...>& func,
std::index_sequence<Indices...> )
{
return method<Ret>
(
name,
typename boost::function<Ret (raw_type&, const CallContext&)>
( boost::bind(
func,
_1,
boost::bind(&Ghost::arg_from_nasal<Args>, _2, Indices)...
))
);
return method<Ret>(name,
typename boost::function<Ret (raw_type&, const CallContext&)>
(std::bind(func,
std::placeholders::_1,
std::bind(&Ghost::arg_from_nasal<Args>,
std::placeholders::_2,
Indices)...)));
}
template<class Ret, class... Args>
@ -1124,24 +1126,20 @@ namespace nasal
naRef(*to_nasal_)(naContext, param_type) = &to_nasal;
// Getter signature: naRef(raw_type&, naContext)
return boost::bind
(
to_nasal_,
_2,
boost::bind(getter, _1)
);
return std::bind(to_nasal_,
std::placeholders::_2,
std::bind(getter, std::placeholders::_1));
}
template<class Param>
setter_t to_setter(void (raw_type::*setter)(Param))
{
// Setter signature: void(raw_type&, naContext, naRef)
return boost::bind
(
setter,
_1,
boost::bind(from_nasal_ptr<Param>::get(), _2, _3)
);
return std::bind(setter,
std::placeholders::_1,
std::bind(from_nasal_ptr<Param>::get(),
std::placeholders::_2,
std::placeholders::_3));
}
/**

View File

@ -22,8 +22,6 @@
#include <ctime>
#include <map>
#include <boost/bind.hpp>
#include <simgear/misc/sg_path.hxx>
#include <simgear/props/props.hxx>
@ -148,7 +146,7 @@ public:
template<class C>
void addStatusCallback(C* instance, void (C::*mem_func)(Catalog*))
{
return addStatusCallback(boost::bind(mem_func, instance, _1));
return addStatusCallback(std::bind(mem_func, instance, std::placeholders::_1));
}
bool isUserEnabled() const;

View File

@ -29,8 +29,6 @@
#include <simgear/structure/SGSharedPtr.hxx>
#include <simgear/io/HTTPRequest.hxx>
#include <boost/bind.hpp>
namespace simgear
{
@ -112,7 +110,7 @@ public:
template<class C>
Install* done(C* instance, void (C::*mem_func)(Install*))
{
return done(boost::bind(mem_func, instance, _1));
return done(std::bind(mem_func, instance, std::placeholders::_1));
}
/**
@ -126,7 +124,7 @@ public:
template<class C>
Install* fail(C* instance, void (C::*mem_func)(Install*))
{
return fail(boost::bind(mem_func, instance, _1));
return fail(std::bind(mem_func, instance, std::placeholders::_1));
}
/**
@ -141,7 +139,7 @@ public:
template<class C>
Install* always(C* instance, void (C::*mem_func)(Install*))
{
return always(boost::bind(mem_func, instance, _1));
return always(std::bind(mem_func, instance, std::placeholders::_1));
}
/**
@ -155,7 +153,11 @@ public:
Install* progress(C* instance,
void (C::*mem_func)(Install*, unsigned int, unsigned int))
{
return progress(boost::bind(mem_func, instance, _1, _2, _3));
return progress(std::bind(mem_func,
instance,
std::placeholders::_1,
std::placeholders::_2,
std::placeholders::_3));
}
private:

View File

@ -9,8 +9,6 @@
#include <iterator>
#include <vector>
#include <boost/bind.hpp>
#include <simgear/structure/Singleton.hxx>
namespace simgear

View File

@ -5,8 +5,6 @@
#include <iterator>
#include <vector>
#include <boost/bind.hpp>
#include <simgear/structure/Singleton.hxx>
#include "props.hxx"

View File

@ -2,8 +2,7 @@
#define SIMGEAR_EXTENDEDPROPERTYADAPTER_HXX 1
#include <algorithm>
#include <boost/bind.hpp>
#include <functional>
#include <simgear/math/SGMath.hxx>
#include <simgear/structure/exception.hxx>
@ -65,7 +64,8 @@ inline void makeChildList(SGPropertyNode* prop, InIterator inBegin,
InIterator inEnd, OutIterator outBegin)
{
std::transform(inBegin, inEnd, outBegin,
boost::bind(static_cast<SGPropertyNode* (SGPropertyNode::*)(const char*, int, bool)>(&SGPropertyNode::getChild), prop, _1, 0, true));
std::bind(static_cast<SGPropertyNode* (SGPropertyNode::*)(const char*, int, bool)>(&SGPropertyNode::getChild),
prop, std::placeholders::_1, 0, true));
}
}

View File

@ -29,7 +29,6 @@ using std::cerr;
# include <boost/algorithm/string/find_iterator.hpp>
# include <boost/algorithm/string/predicate.hpp>
# include <boost/algorithm/string/classification.hpp>
# include <boost/bind.hpp>
# include <boost/functional/hash.hpp>
# include <boost/range.hpp>
# include <simgear/compiler.h>

View File

@ -35,7 +35,6 @@
#include <unordered_map>
#include <mutex>
#include <boost/bind.hpp>
#include <boost/functional/hash.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
@ -880,7 +879,6 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
const SGReaderWriterOptions*
options)
{
using namespace boost;
if (!isAttributeActive(effect, prop))
return;
PropertyList pVertShaders = prop->getChildren("vertex-shader");
@ -889,12 +887,15 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
PropertyList pAttributes = prop->getChildren("attribute");
ProgramKey prgKey;
std::back_insert_iterator<vector<ShaderKey> > inserter(prgKey.shaders);
transform(pVertShaders.begin(), pVertShaders.end(), inserter,
boost::bind(makeShaderKey, _1, Shader::VERTEX));
transform(pGeomShaders.begin(), pGeomShaders.end(), inserter,
boost::bind(makeShaderKey, _1, Shader::GEOMETRY));
transform(pFragShaders.begin(), pFragShaders.end(), inserter,
boost::bind(makeShaderKey, _1, Shader::FRAGMENT));
std::transform(pVertShaders.begin(), pVertShaders.end(), inserter,
[] (SGPropertyNode_ptr& ptr) {
return makeShaderKey(ptr, Shader::VERTEX); });
std::transform(pGeomShaders.begin(), pGeomShaders.end(), inserter,
[] (SGPropertyNode_ptr& ptr) {
return makeShaderKey(ptr, Shader::GEOMETRY); });
std::transform(pFragShaders.begin(), pFragShaders.end(), inserter,
[] (SGPropertyNode_ptr& ptr) {
return makeShaderKey(ptr, Shader::FRAGMENT); });
for (PropertyList::iterator itr = pAttributes.begin(),
e = pAttributes.end();
itr != e;

View File

@ -29,7 +29,6 @@
#include <osg/Object>
#include <osgDB/Registry>
#include <boost/bind.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
@ -633,8 +632,9 @@ initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
SetterReturn (ObjType::*setter)(const OSGParamType),
const SGReaderWriterOptions* options)
{
initFromParameters<OSGParamType>(effect, prop, obj,
boost::bind(setter, _1, _2), options);
initFromParameters<OSGParamType>(effect, prop, obj,
std::bind(setter, std::placeholders::_1, std::placeholders::_2),
options);
}
/*
@ -694,8 +694,8 @@ initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
NameItrType nameItr, const SGReaderWriterOptions* options)
{
initFromParameters<OSGParamType>(effect, prop, obj,
boost::bind(setter, _1, _2), nameItr,
options);
std::bind(setter, std::placeholders::_1, std::placeholders::_2),
nameItr, options);
}
extern const char* colorFields[];
}

View File

@ -25,8 +25,6 @@
#include <cstring>
#include <cassert>
#include <boost/bind.hpp>
#include <osg/Version>
#include <osg/Geode>
#include <osg/MatrixTransform>
@ -197,10 +195,10 @@ void makeEffectAnimations(PropertyList& animation_nodes,
}
}
animation_nodes.erase(remove_if(animation_nodes.begin(),
animation_nodes.end(),
!boost::bind(&SGPropertyNode_ptr::valid,
_1)),
animation_nodes.erase(std::remove_if(animation_nodes.begin(),
animation_nodes.end(),
[] (const SGPropertyNode_ptr& ptr) {
return !ptr.valid(); }),
animation_nodes.end());
}
}

View File

@ -31,7 +31,6 @@
#include <utility>
#include <string>
#include <sstream>
#include <boost/bind.hpp>
#include <cstring> // for strcmp
#include <cassert>
@ -854,12 +853,12 @@ ExpParserRegistrar leRegistrar("less-equal", predParser<LessEqualExpression>);
template<typename Logicop>
Expression* logicopParser(const SGPropertyNode* exp, Parser* parser)
{
using namespace boost;
vector<Expression*> children;
std::vector<Expression*> children;
parser->readChildren(exp, children);
vector<Expression*>::iterator notBool =
find_if(children.begin(), children.end(),
boost::bind(&Expression::getType, _1) != BOOL);
std::vector<Expression*>::const_iterator notBool =
std::find_if(children.begin(), children.end(),
[] (const Expression* const e) {
return e->getType () != BOOL; });
if (notBool != children.end())
throw("non boolean operand to logical expression");
Logicop *expr = new Logicop;
@ -873,9 +872,10 @@ ExpParserRegistrar orRegistrar("or", logicopParser<OrExpression>);
size_t BindingLayout::addBinding(const string& name, Type type)
{
//XXX error checkint
vector<VariableBinding>::iterator itr
= find_if(bindings.begin(), bindings.end(),
boost::bind(&VariableBinding::name, _1) == name);
std::vector<VariableBinding>::const_iterator itr =
std::find_if(bindings.begin(), bindings.end(),
[&name] (const VariableBinding& v) {
return v.name == name; });
if (itr != bindings.end())
return itr->location;
size_t result = bindings.size();
@ -886,11 +886,10 @@ size_t BindingLayout::addBinding(const string& name, Type type)
bool BindingLayout::findBinding(const std::string& name,
VariableBinding& result) const
{
using namespace std;
using namespace boost;
vector<VariableBinding>::const_iterator itr
= find_if(bindings.begin(), bindings.end(),
boost::bind(&VariableBinding::name, _1) == name);
std::vector<VariableBinding>::const_iterator itr =
std::find_if(bindings.begin(), bindings.end(),
[&name] (const VariableBinding& v) {
return v.name == name; });
if (itr != bindings.end()) {
result = *itr;
return true;