diff --git a/src/ripple/basics/comparators.h b/src/ripple/basics/comparators.h new file mode 100644 index 000000000..ce782dcd3 --- /dev/null +++ b/src/ripple/basics/comparators.h @@ -0,0 +1,76 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2012, 2013 Ripple Labs Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef RIPPLE_BASICS_COMPARATORS_H_INCLUDED +#define RIPPLE_BASICS_COMPARATORS_H_INCLUDED + +#include + +namespace ripple { + +#ifdef _MSC_VER + +/* + * MSVC 2019 version 16.9.0 added [[nodiscard]] to the std comparison + * operator() functions. boost::bimap checks that the comparitor is a + * BinaryFunction, in part by calling the function and ignoring the value. + * These two things don't play well together. These wrapper classes simply + * strip [[nodiscard]] from operator() for use in boost::bimap. + * + * See also: + * https://www.boost.org/doc/libs/1_75_0/libs/bimap/doc/html/boost_bimap/the_tutorial/controlling_collection_types.html + */ + +template +struct less +{ + using result_type = bool; + + constexpr bool + operator()(const T& left, const T& right) const + { + return std::less()(left, right); + } +}; + +template +struct equal_to +{ + using result_type = bool; + + constexpr bool + operator()(const T& left, const T& right) const + { + return std::equal_to()(left, right); + } +}; + +#else + +template +using less = std::less; + +template +using equal_to = std::equal_to; + +#endif + +} // namespace ripple + +#endif diff --git a/src/ripple/peerfinder/impl/Bootcache.h b/src/ripple/peerfinder/impl/Bootcache.h index bdcdffd43..eb6455879 100644 --- a/src/ripple/peerfinder/impl/Bootcache.h +++ b/src/ripple/peerfinder/impl/Bootcache.h @@ -20,6 +20,7 @@ #ifndef RIPPLE_PEERFINDER_BOOTCACHE_H_INCLUDED #define RIPPLE_PEERFINDER_BOOTCACHE_H_INCLUDED +#include #include #include #include @@ -81,8 +82,11 @@ private: int m_valence; }; - using left_t = boost::bimaps::unordered_set_of; - using right_t = boost::bimaps::multiset_of; + using left_t = boost::bimaps::unordered_set_of< + beast::IP::Endpoint, + boost::hash, + ripple::equal_to>; + using right_t = boost::bimaps::multiset_of>; using map_type = boost::bimap; using value_type = map_type::value_type; diff --git a/src/test/csf/ledgers.h b/src/test/csf/ledgers.h index e5bd479cd..635fbec21 100644 --- a/src/test/csf/ledgers.h +++ b/src/test/csf/ledgers.h @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -242,7 +243,9 @@ private: */ class LedgerOracle { - using InstanceMap = boost::bimaps::bimap; + using InstanceMap = boost::bimaps::bimap< + boost::bimaps::set_of>, + boost::bimaps::set_of>>; using InstanceEntry = InstanceMap::value_type; // Set of all known ledgers; note this is never pruned