Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress warnings with latest Apple clang/libc++. #4486

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/ripple/beast/container/detail/aged_ordered_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,19 @@ class aged_ordered_container
class pair_value_compare
: public beast::detail::empty_base_optimization<Compare>
#ifdef _LIBCPP_VERSION
#if _LIBCPP_VERSION >= 15006
,
public std::__binary_function<value_type, value_type, bool>
#else
,
public std::binary_function<value_type, value_type, bool>
#endif
#endif
{
public:
#ifndef _LIBCPP_VERSION
using first_argument = value_type;
using second_argument = value_type;
using result_type = bool;
#endif

bool
operator()(value_type const& lhs, value_type const& rhs) const
Expand Down Expand Up @@ -188,16 +191,19 @@ class aged_ordered_container
class KeyValueCompare
: public beast::detail::empty_base_optimization<Compare>
#ifdef _LIBCPP_VERSION
#if _LIBCPP_VERSION >= 15006
,
public std::__binary_function<Key, element, bool>
#else
,
public std::binary_function<Key, element, bool>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would adding the double underscore do?

Copy link
Contributor Author

@HowardHinnant HowardHinnant Apr 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This takes advantage of a libc++-only feature. std::binary_function is marked deprecated. But as an implementation technique of libc++, std::__binary_function has the same functionality as std::binary_function but is not marked deprecated. This is done as a hack in libc++ to avoid rewriting things that used to depend on std::binary_function but no longer do. And that hack is reused here in rippled.

If the hack goes away (libc++ comes into conformance), then we will get a compile-time error, and all we'll have to do is remove the code within #ifdef _LIBCPP_VERSION.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

#endif
#endif
{
public:
#ifndef _LIBCPP_VERSION
using first_argument = Key;
using second_argument = element;
using result_type = bool;
#endif

KeyValueCompare() = default;

Expand Down
14 changes: 10 additions & 4 deletions src/ripple/beast/container/detail/aged_unordered_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,18 @@ class aged_unordered_container
// VFALCO TODO hoist to remove template argument dependencies
class ValueHash : private beast::detail::empty_base_optimization<Hash>
#ifdef _LIBCPP_VERSION
#if _LIBCPP_VERSION >= 15006
,
public std::__unary_function<element, std::size_t>
#else
,
public std::unary_function<element, std::size_t>
#endif
#endif
{
public:
#ifndef _LIBCPP_VERSION
using argument_type = element;
using result_type = size_t;
#endif

ValueHash()
{
Expand Down Expand Up @@ -193,16 +196,19 @@ class aged_unordered_container
class KeyValueEqual
: private beast::detail::empty_base_optimization<KeyEqual>
#ifdef _LIBCPP_VERSION
#if _LIBCPP_VERSION >= 15006
,
public std::__binary_function<Key, element, bool>
#else
,
public std::binary_function<Key, element, bool>
#endif
#endif
{
public:
#ifndef _LIBCPP_VERSION
using first_argument_type = Key;
using second_argument_type = element;
using result_type = bool;
#endif

KeyValueEqual()
{
Expand Down
7 changes: 0 additions & 7 deletions src/ripple/peerfinder/impl/Bootcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,10 @@ class Bootcache
using value_type = map_type::value_type;

struct Transform
#ifdef _LIBCPP_VERSION
: std::unary_function<
map_type::right_map::const_iterator::value_type const&,
beast::IP::Endpoint const&>
#endif
{
#ifndef _LIBCPP_VERSION
using first_argument_type =
map_type::right_map::const_iterator::value_type const&;
using result_type = beast::IP::Endpoint const&;
#endif

explicit Transform() = default;

Expand Down
11 changes: 0 additions & 11 deletions src/ripple/peerfinder/impl/Livecache.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,9 @@ class LivecacheBase
public:
// Iterator transformation to extract the endpoint from Element
struct Transform
#ifdef _LIBCPP_VERSION
: public std::unary_function<Element, Endpoint>
#endif
{
#ifndef _LIBCPP_VERSION
using first_argument = Element;
using result_type = Endpoint;
#endif

explicit Transform() = default;

Expand Down Expand Up @@ -239,15 +234,9 @@ class Livecache : protected detail::LivecacheBase

template <bool IsConst>
struct Transform
#ifdef _LIBCPP_VERSION
: public std::
unary_function<typename lists_type::value_type, Hop<IsConst>>
#endif
{
#ifndef _LIBCPP_VERSION
using first_argument = typename lists_type::value_type;
using result_type = Hop<IsConst>;
#endif

explicit Transform() = default;

Expand Down
1 change: 1 addition & 0 deletions src/ripple/shamap/impl/SHAMapInnerNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ SHAMapInnerNode::invariants(bool is_root) const
}
}

(void)count;
if (!is_root)
{
assert(hash_.isNonZero());
Expand Down