Commit 434cd5c0 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

std::unary_function and binary removed from C++17

Fixes building in MSVS with -std:c++17

Refs: https://en.cppreference.com/w/cpp/utility/functional/unary_function
Change-Id: Ibb05b6810cae029aae33957f3eb52cc3a9e4863e
Reviewed-on: https://chromium-review.googlesource.com/c/1227322
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57428}
parent d85b5b75
......@@ -137,18 +137,17 @@ V8_INLINE size_t hash_value(std::pair<T1, T2> const& v) {
return hash_combine(v.first, v.second);
}
template <typename T>
struct hash : public std::unary_function<T, size_t> {
struct hash {
V8_INLINE size_t operator()(T const& v) const { return hash_value(v); }
};
#define V8_BASE_HASH_SPECIALIZE(type) \
template <> \
struct hash<type> : public std::unary_function<type, size_t> { \
V8_INLINE size_t operator()(type const v) const { \
return ::v8::base::hash_value(v); \
} \
#define V8_BASE_HASH_SPECIALIZE(type) \
template <> \
struct hash<type> { \
V8_INLINE size_t operator()(type const v) const { \
return ::v8::base::hash_value(v); \
} \
};
V8_BASE_HASH_SPECIALIZE(bool)
V8_BASE_HASH_SPECIALIZE(signed char)
......@@ -166,7 +165,7 @@ V8_BASE_HASH_SPECIALIZE(double)
#undef V8_BASE_HASH_SPECIALIZE
template <typename T>
struct hash<T*> : public std::unary_function<T*, size_t> {
struct hash<T*> {
V8_INLINE size_t operator()(T* const v) const {
return ::v8::base::hash_value(v);
}
......@@ -181,10 +180,10 @@ struct hash<T*> : public std::unary_function<T*, size_t> {
// hash data structure based on the bitwise representation of types.
template <typename T>
struct bit_equal_to : public std::binary_function<T, T, bool> {};
struct bit_equal_to {};
template <typename T>
struct bit_hash : public std::unary_function<T, size_t> {};
struct bit_hash {};
#define V8_BASE_BIT_SPECIALIZE_TRIVIAL(type) \
template <> \
......@@ -203,19 +202,19 @@ V8_BASE_BIT_SPECIALIZE_TRIVIAL(long long) // NOLINT(runtime/int)
V8_BASE_BIT_SPECIALIZE_TRIVIAL(unsigned long long) // NOLINT(runtime/int)
#undef V8_BASE_BIT_SPECIALIZE_TRIVIAL
#define V8_BASE_BIT_SPECIALIZE_BIT_CAST(type, btype) \
template <> \
struct bit_equal_to<type> : public std::binary_function<type, type, bool> { \
V8_INLINE bool operator()(type lhs, type rhs) const { \
return bit_cast<btype>(lhs) == bit_cast<btype>(rhs); \
} \
}; \
template <> \
struct bit_hash<type> : public std::unary_function<type, size_t> { \
V8_INLINE size_t operator()(type v) const { \
hash<btype> h; \
return h(bit_cast<btype>(v)); \
} \
#define V8_BASE_BIT_SPECIALIZE_BIT_CAST(type, btype) \
template <> \
struct bit_equal_to<type> { \
V8_INLINE bool operator()(type lhs, type rhs) const { \
return bit_cast<btype>(lhs) == bit_cast<btype>(rhs); \
} \
}; \
template <> \
struct bit_hash<type> { \
V8_INLINE size_t operator()(type v) const { \
hash<btype> h; \
return h(bit_cast<btype>(v)); \
} \
};
V8_BASE_BIT_SPECIALIZE_BIT_CAST(float, uint32_t)
V8_BASE_BIT_SPECIALIZE_BIT_CAST(double, uint64_t)
......
......@@ -186,14 +186,14 @@ class Handle final : public HandleBase {
bool equals(Handle<T> other) const { return address() == other.address(); }
// Provide function object for location equality comparison.
struct equal_to : public std::binary_function<Handle<T>, Handle<T>, bool> {
struct equal_to {
V8_INLINE bool operator()(Handle<T> lhs, Handle<T> rhs) const {
return lhs.equals(rhs);
}
};
// Provide function object for location hashing.
struct hash : public std::unary_function<Handle<T>, size_t> {
struct hash {
V8_INLINE size_t operator()(Handle<T> const& handle) const {
return base::hash<Address>()(handle.address());
}
......
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