]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[919-bind1st-and-bind2nd-were-deprecated] Updated bind1st/bind2nd with bind or lambda
authorFrancis Dupont <fdupont@isc.org>
Sat, 21 Sep 2019 16:40:15 +0000 (18:40 +0200)
committerFrancis Dupont <fdupont@isc.org>
Tue, 22 Oct 2019 07:40:17 +0000 (03:40 -0400)
src/lib/dns/name.cc
src/lib/dns/tests/masterload_unittest.cc
src/lib/hooks/callout_manager.cc
src/lib/hooks/callout_manager.h
src/lib/util/range_utilities.h

index ec9f2f799e450610f5631817ae2a16e32cb56215..3f75fa00642a33bf79a1ca988ac4ea092e3baf0d 100644 (file)
@@ -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<char>(), 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<char>(), -offsets_[first]));
+              [&](char x) { return (x - offsets_[first]); });
 
     //
     // Set up the new name.  At this point the tail of the new offsets specifies
index ed35a7f0e0869353cb3b08afb1b83103f07d2e96..90c6a275917b372e118fb55581f09e3580a6ea8e 100644 (file)
@@ -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) {
index a9939588fb23e5fb804e9a7303f4423e34d2c6d0..fb878350519d1e760b6718b005170b8e3c6485dd 100644 (file)
@@ -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<CalloutEntry>(),
-                                                     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.
index 66afede2160102e529db8bbefd96745e4ca92c00..b1b012b4c8a03816a02e95ff9d650155df0760e8 100644 (file)
@@ -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<CalloutEntry, CalloutEntry, bool> {
-    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
index 14f4b9a025523794b45164f56e3e3c54ecab7b0d..ae00c419f1582cc389dd6a13e9682dbfd426dbf4 100644 (file)
@@ -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 <typename Iterator>
 bool
 isRangeZero(Iterator begin, Iterator end) {
-    return (std::find_if(begin, end,
-                         std::bind1st(std::not_equal_to<int>(), 0))
+    return (std::find_if(begin, end, [] (int x) { return (0 != x); })
             == end);
 }