You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2024/09/14 00:09:46 UTC
(kudu) 04/09: [gutil] fix compilation with clang 15
This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch branch-1.17.x
in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 3e2640fba9f96ef9d2e1d56a43fdd526081f5e7d
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Mon Mar 25 21:30:20 2024 -0700
[gutil] fix compilation with clang 15
std::{binary,unary}_function have been deprecated since C++11 and
removed in C++17 [1], and it seems that CLANG 15 which comes with
Xcode 15.3 on macOS enforces this particular part of the C++17 standard.
In this instance, it's easy to address the issue because nothing
essential was used from std::unary_function and std::binary_function
but just typedefs which are no longer needed by the new standard library
anyway. Since Kudu switched to C++17 a long time ago [2], the solution
is to stop inheriting from the deprecated classes.
[1] https://en.cppreference.com/w/cpp/utility/functional/unary_function
[2] https://github.com/apache/kudu/commit/e432e637e282ba87d41c02088a801f0838571edc
Change-Id: I3329427c3babd57418c83ab2401b7c4d29e14020
Reviewed-on: http://gerrit.cloudera.org:8080/21206
Tested-by: Alexey Serbin <al...@apache.org>
Reviewed-by: Mahesh Reddy <mr...@cloudera.com>
Reviewed-by: Abhishek Chennaka <ac...@cloudera.com>
(cherry picked from commit 4dc4100fe5cf994cccb5d87cc398e79dde038686)
Reviewed-on: http://gerrit.cloudera.org:8080/21789
Reviewed-by: Alexey Serbin <al...@apache.org>
Tested-by: Abhishek Chennaka <ac...@cloudera.com>
---
src/kudu/gutil/stl_util.h | 16 +++++-----------
src/kudu/gutil/strings/human_readable.h | 6 ++----
src/kudu/gutil/strings/numbers.h | 12 ++++--------
src/kudu/gutil/strings/util.h | 4 ++--
4 files changed, 13 insertions(+), 25 deletions(-)
diff --git a/src/kudu/gutil/stl_util.h b/src/kudu/gutil/stl_util.h
index 2eeb6285b..7370e987a 100644
--- a/src/kudu/gutil/stl_util.h
+++ b/src/kudu/gutil/stl_util.h
@@ -682,8 +682,7 @@ bool STLIncludes(const SortedSTLContainerA &a,
// the contents of an STL map. For other sample usage, see the unittest.
template<typename Pair, typename UnaryOp>
-class UnaryOperateOnFirst
- : public std::unary_function<Pair, typename UnaryOp::result_type> {
+class UnaryOperateOnFirst {
public:
UnaryOperateOnFirst() {
}
@@ -705,8 +704,7 @@ UnaryOperateOnFirst<Pair, UnaryOp> UnaryOperate1st(const UnaryOp& f) {
}
template<typename Pair, typename UnaryOp>
-class UnaryOperateOnSecond
- : public std::unary_function<Pair, typename UnaryOp::result_type> {
+class UnaryOperateOnSecond {
public:
UnaryOperateOnSecond() {
}
@@ -728,8 +726,7 @@ UnaryOperateOnSecond<Pair, UnaryOp> UnaryOperate2nd(const UnaryOp& f) {
}
template<typename Pair, typename BinaryOp>
-class BinaryOperateOnFirst
- : public std::binary_function<Pair, Pair, typename BinaryOp::result_type> {
+class BinaryOperateOnFirst {
public:
BinaryOperateOnFirst() {
}
@@ -753,8 +750,7 @@ BinaryOperateOnFirst<Pair, BinaryOp> BinaryOperate1st(const BinaryOp& f) {
}
template<typename Pair, typename BinaryOp>
-class BinaryOperateOnSecond
- : public std::binary_function<Pair, Pair, typename BinaryOp::result_type> {
+class BinaryOperateOnSecond {
public:
BinaryOperateOnSecond() {
}
@@ -790,9 +786,7 @@ BinaryOperateOnSecond<Pair, BinaryOp> BinaryOperate2nd(const BinaryOp& f) {
// F has to be a model of AdaptableBinaryFunction.
// G1 and G2 have to be models of AdabtableUnaryFunction.
template<typename F, typename G1, typename G2>
-class BinaryComposeBinary : public std::binary_function<typename G1::argument_type,
- typename G2::argument_type,
- typename F::result_type> {
+class BinaryComposeBinary {
public:
BinaryComposeBinary(F f, G1 g1, G2 g2) : f_(f), g1_(g1), g2_(g2) { }
diff --git a/src/kudu/gutil/strings/human_readable.h b/src/kudu/gutil/strings/human_readable.h
index a19b9e797..07c848953 100644
--- a/src/kudu/gutil/strings/human_readable.h
+++ b/src/kudu/gutil/strings/human_readable.h
@@ -75,16 +75,14 @@ class HumanReadableNumBytes {
// See documentation at HumanReadableNumBytes::LessThan().
-struct humanreadablebytes_less
- : public std::binary_function<const std::string&, const std::string&, bool> {
+struct humanreadablebytes_less {
bool operator()(const std::string& a, const std::string &b) const {
return HumanReadableNumBytes::LessThan(a, b);
}
};
// See documentation at HumanReadableNumBytes::LessThan().
-struct humanreadablebytes_greater
- : public std::binary_function<const std::string&, const std::string&, bool> {
+struct humanreadablebytes_greater {
bool operator()(const std::string& a, const std::string &b) const {
return HumanReadableNumBytes::LessThan(b, a);
}
diff --git a/src/kudu/gutil/strings/numbers.h b/src/kudu/gutil/strings/numbers.h
index f85889160..b3bc3da82 100644
--- a/src/kudu/gutil/strings/numbers.h
+++ b/src/kudu/gutil/strings/numbers.h
@@ -332,29 +332,25 @@ bool AutoDigitLessThan(const char* a, int alen,
bool StrictAutoDigitLessThan(const char* a, int alen,
const char* b, int blen);
-struct autodigit_less
- : public std::binary_function<const std::string&, const std::string&, bool> {
+struct autodigit_less {
bool operator()(const std::string& a, const std::string& b) const {
return AutoDigitLessThan(a.data(), a.size(), b.data(), b.size());
}
};
-struct autodigit_greater
- : public std::binary_function<const std::string&, const std::string&, bool> {
+struct autodigit_greater {
bool operator()(const std::string& a, const std::string& b) const {
return AutoDigitLessThan(b.data(), b.size(), a.data(), a.size());
}
};
-struct strict_autodigit_less
- : public std::binary_function<const std::string&, const std::string&, bool> {
+struct strict_autodigit_less {
bool operator()(const std::string& a, const std::string& b) const {
return StrictAutoDigitLessThan(a.data(), a.size(), b.data(), b.size());
}
};
-struct strict_autodigit_greater
- : public std::binary_function<const std::string&, const std::string&, bool> {
+struct strict_autodigit_greater {
bool operator()(const std::string& a, const std::string& b) const {
return StrictAutoDigitLessThan(b.data(), b.size(), a.data(), a.size());
}
diff --git a/src/kudu/gutil/strings/util.h b/src/kudu/gutil/strings/util.h
index e7f9c496d..355659de4 100644
--- a/src/kudu/gutil/strings/util.h
+++ b/src/kudu/gutil/strings/util.h
@@ -260,7 +260,7 @@ char* AdjustedLastPos(const char* str, char separator, int n);
// Compares two char* strings for equality. (Works with NULL, which compares
// equal only to another NULL). Useful in hash tables:
// hash_map<const char*, Value, hash<const char*>, streq> ht;
-struct streq : public std::binary_function<const char*, const char*, bool> {
+struct streq {
bool operator()(const char* s1, const char* s2) const {
return ((s1 == 0 && s2 == 0) ||
(s1 && s2 && *s1 == *s2 && strcmp(s1, s2) == 0));
@@ -270,7 +270,7 @@ struct streq : public std::binary_function<const char*, const char*, bool> {
// Compares two char* strings. (Works with NULL, which compares greater than any
// non-NULL). Useful in maps:
// map<const char*, Value, strlt> m;
-struct strlt : public std::binary_function<const char*, const char*, bool> {
+struct strlt {
bool operator()(const char* s1, const char* s2) const {
return (s1 != s2) && (s2 == 0 || (s1 != 0 && strcmp(s1, s2) < 0));
}