Commit b12fa337 authored by Francis Dupont's avatar Francis Dupont

[919-bind1st-and-bind2nd-were-deprecated] Updated bind1st/bind2nd with bind or lambda

parent 3cbaebdc
......@@ -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
......
// 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) {
......
// 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.
......
// 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
......
// 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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment