From: Francis Dupont Date: Sat, 21 Sep 2019 16:40:15 +0000 (+0200) Subject: [919-bind1st-and-bind2nd-were-deprecated] Updated bind1st/bind2nd with bind or lambda X-Git-Tag: Kea-1.7.1~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b12fa3374454c9c0d749557d5532aab55dbc58d9;p=thirdparty%2Fkea.git [919-bind1st-and-bind2nd-were-deprecated] Updated bind1st/bind2nd with bind or lambda --- diff --git a/src/lib/dns/name.cc b/src/lib/dns/name.cc index ec9f2f799e..3f75fa0064 100644 --- a/src/lib/dns/name.cc +++ b/src/lib/dns/name.cc @@ -603,7 +603,7 @@ Name::concatenate(const Name& suffix) const { retname.offsets_.assign(&offsets_[0], &offsets_[0] + labelcount_ - 1); transform(suffix.offsets_.begin(), suffix.offsets_.end(), back_inserter(retname.offsets_), - bind2nd(plus(), length_ - 1)); + [this] (char x) { return (x + length_ - 1); }); isc_throw_assert(retname.offsets_.size() == labels); retname.labelcount_ = labels; @@ -657,7 +657,7 @@ Name::split(const unsigned int first, const unsigned int n) const { retname.offsets_.reserve(newlabels); transform(offsets_.begin() + first, offsets_.begin() + first + newlabels, back_inserter(retname.offsets_), - bind2nd(plus(), -offsets_[first])); + [&](char x) { return (x - offsets_[first]); }); // // Set up the new name. At this point the tail of the new offsets specifies diff --git a/src/lib/dns/tests/masterload_unittest.cc b/src/lib/dns/tests/masterload_unittest.cc index ed35a7f0e0..90c6a27591 100644 --- a/src/lib/dns/tests/masterload_unittest.cc +++ b/src/lib/dns/tests/masterload_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2010-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -95,7 +95,7 @@ TEST_F(MasterLoadTest, loadWithFunctionCallback) { // object) rr_stream << txt_rr << a_rr1 << soa_rr; masterLoad(rr_stream, origin, zclass, - bind2nd(ptr_fun(testCallback), &results)); + boost::bind(&testCallback, _1, &results)); ASSERT_EQ(3, results.size()); EXPECT_EQ(txt_rr, results[0]->toText()); EXPECT_EQ(a_rr1, results[1]->toText()); @@ -292,7 +292,7 @@ TEST_F(MasterLoadTest, loadWithNoEOF) { TEST_F(MasterLoadTest, loadEmpty) { // an unusual case: empty input. load must succeed with an empty result. masterLoad(rr_stream, origin, zclass, callback); - EXPECT_EQ(0, results.size()); + EXPECT_EQ(0, results.size()); } TEST_F(MasterLoadTest, loadWithBeginningSpace) { diff --git a/src/lib/hooks/callout_manager.cc b/src/lib/hooks/callout_manager.cc index a9939588fb..fb87835051 100644 --- a/src/lib/hooks/callout_manager.cc +++ b/src/lib/hooks/callout_manager.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -268,8 +268,8 @@ CalloutManager::deregisterCallout(const std::string& name, CalloutPtr callout) { // all the matching elements. hook_vector_[hook_index].erase(remove_if(hook_vector_[hook_index].begin(), hook_vector_[hook_index].end(), - bind1st(equal_to(), - target)), + [&target] (CalloutEntry x) { + return (x == target); }), hook_vector_[hook_index].end()); // Return an indication of whether anything was removed. @@ -306,8 +306,9 @@ CalloutManager::deregisterAllCallouts(const std::string& name) { // Remove all callouts matching this library. hook_vector_[hook_index].erase(remove_if(hook_vector_[hook_index].begin(), hook_vector_[hook_index].end(), - bind1st(CalloutLibraryEqual(), - target)), + [&target] (CalloutEntry x) { + return (x.first == target.first); + }), hook_vector_[hook_index].end()); // Return an indication of whether anything was removed. diff --git a/src/lib/hooks/callout_manager.h b/src/lib/hooks/callout_manager.h index 66afede216..b1b012b4c8 100644 --- a/src/lib/hooks/callout_manager.h +++ b/src/lib/hooks/callout_manager.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -407,25 +407,6 @@ private: /// @throw NoSuchLibrary Library index is not valid. void checkLibraryIndex(int library_index) const; - /// @brief Compare two callout entries for library equality - /// - /// This is used in callout removal code when all callouts on a hook for a - /// given library are being removed. It checks whether two callout entries - /// have the same library index. - /// - /// @param ent1 First callout entry to check - /// @param ent2 Second callout entry to check - /// - /// @return bool true if the library entries are the same - class CalloutLibraryEqual : - public std::binary_function { - public: - bool operator()(const CalloutEntry& ent1, - const CalloutEntry& ent2) const { - return (ent1.first == ent2.first); - } - }; - // Member variables /// Reference to the singleton ServerHooks object. See the diff --git a/src/lib/util/range_utilities.h b/src/lib/util/range_utilities.h index 14f4b9a025..ae00c419f1 100644 --- a/src/lib/util/range_utilities.h +++ b/src/lib/util/range_utilities.h @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -27,8 +27,7 @@ namespace util { template bool isRangeZero(Iterator begin, Iterator end) { - return (std::find_if(begin, end, - std::bind1st(std::not_equal_to(), 0)) + return (std::find_if(begin, end, [] (int x) { return (0 != x); }) == end); }