From dd3e170e08b9628927b69f9cdece0291bda52871 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sat, 9 Jan 2016 18:47:26 -0500 Subject: [PATCH] Correct handling of comparators in boost::intrusive: This facilitates the port of rippled to boost 1.60 while maintaining compatibility with previous versions of boost. --- .../container/detail/aged_ordered_container.h | 24 +++++++++++++++---- beast/http/headers.h | 14 ++++++++++- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/beast/container/detail/aged_ordered_container.h b/beast/container/detail/aged_ordered_container.h index 65418f7c6..4ebb64d53 100644 --- a/beast/container/detail/aged_ordered_container.h +++ b/beast/container/detail/aged_ordered_container.h @@ -199,9 +199,7 @@ private: , public std::binary_function { public: - KeyValueCompare () - { - } + KeyValueCompare () = default; KeyValueCompare (Compare const& compare) : empty_base_optimization (compare) @@ -234,6 +232,11 @@ private: return this->member() (extract (e.value), k); } + bool operator() (element const& x, element const& y) const + { + return this->member() (extract (x.value), extract (y.value)); + } + Compare& compare() { return empty_base_optimization ::member(); @@ -251,10 +254,12 @@ private: using cont_type = typename std::conditional < IsMulti, typename boost::intrusive::make_multiset + boost::intrusive::constant_time_size , + boost::intrusive::compare >::type, typename boost::intrusive::make_set + boost::intrusive::constant_time_size , + boost::intrusive::compare >::type >::type; @@ -1254,6 +1259,7 @@ aged_ordered_container ( clock_type& clock, Compare const& comp) : m_config (clock, comp) + , m_cont (comp) { } @@ -1275,6 +1281,7 @@ aged_ordered_container ( Compare const& comp, Allocator const& alloc) : m_config (clock, comp, alloc) + , m_cont (comp) { } @@ -1297,6 +1304,7 @@ aged_ordered_container (InputIt first, InputIt last, clock_type& clock, Compare const& comp) : m_config (clock, comp) + , m_cont (comp) { insert (first, last); } @@ -1322,6 +1330,7 @@ aged_ordered_container (InputIt first, InputIt last, Compare const& comp, Allocator const& alloc) : m_config (clock, comp, alloc) + , m_cont (comp) { insert (first, last); } @@ -1331,6 +1340,7 @@ template :: aged_ordered_container (aged_ordered_container const& other) : m_config (other.m_config) + , m_cont (other.m_cont.comp()) { insert (other.cbegin(), other.cend()); } @@ -1341,6 +1351,7 @@ aged_ordered_container :: aged_ordered_container (aged_ordered_container const& other, Allocator const& alloc) : m_config (other.m_config, alloc) + , m_cont (other.m_cont.comp()) { insert (other.cbegin(), other.cend()); } @@ -1361,6 +1372,7 @@ aged_ordered_container :: aged_ordered_container (aged_ordered_container&& other, Allocator const& alloc) : m_config (std::move (other.m_config), alloc) + , m_cont (std::move(other.m_cont.comp())) { insert (other.cbegin(), other.cend()); other.clear (); @@ -1383,6 +1395,7 @@ aged_ordered_container (std::initializer_list init, clock_type& clock, Compare const& comp) : m_config (clock, comp) + , m_cont (comp) { insert (init.begin(), init.end()); } @@ -1406,6 +1419,7 @@ aged_ordered_container (std::initializer_list init, Compare const& comp, Allocator const& alloc) : m_config (clock, comp, alloc) + , m_cont (comp) { insert (init.begin(), init.end()); } diff --git a/beast/http/headers.h b/beast/http/headers.h index c010dd757..098580994 100644 --- a/beast/http/headers.h +++ b/beast/http/headers.h @@ -64,6 +64,9 @@ private: template bool operator() (element const& lhs, String const& rhs) const; + + bool + operator() (element const& lhs, element const& rhs) const; }; struct transform @@ -81,7 +84,8 @@ private: >::type; using set_t = boost::intrusive::make_set + boost::intrusive::constant_time_size , + boost::intrusive::compare >::type; list_t list_; @@ -187,6 +191,14 @@ headers::less::operator() ( return beast::ci_less::operator() (lhs.data.first, rhs); } +inline +bool +headers::less::operator() ( + element const& lhs, element const& rhs) const +{ + return beast::ci_less::operator() (lhs.data.first, rhs.data.first); +} + //------------------------------------------------------------------------------ inline