20 #ifndef BEAST_CONTAINER_DETAIL_AGED_UNORDERED_CONTAINER_H_INCLUDED
21 #define BEAST_CONTAINER_DETAIL_AGED_UNORDERED_CONTAINER_H_INCLUDED
23 #include <ripple/beast/container/detail/aged_container_iterator.h>
24 #include <ripple/beast/container/detail/aged_associative_container.h>
25 #include <ripple/beast/container/detail/empty_base_optimization.h>
26 #include <ripple/beast/container/aged_container.h>
27 #include <ripple/beast/clock/abstract_clock.h>
28 #include <boost/intrusive/list.hpp>
29 #include <boost/intrusive/unordered_set.hpp>
51 #ifndef BEAST_NO_CXX14_IS_PERMUTATION
52 #define BEAST_NO_CXX14_IS_PERMUTATION 1
114 : boost::intrusive::unordered_set_base_hook <
115 boost::intrusive::link_mode <
116 boost::intrusive::normal_link>
118 , boost::intrusive::list_base_hook <
119 boost::intrusive::link_mode <
120 boost::intrusive::normal_link>
156 :
value (
std::forward <Args> (args)...)
168 #ifdef _LIBCPP_VERSION
173 #ifndef _LIBCPP_VERSION
194 return this->member();
199 return this->member();
207 #ifdef _LIBCPP_VERSION
212 #ifndef _LIBCPP_VERSION
231 bool operator() (K
const& k,
element const& e)
const
237 bool operator() (element
const& e, K
const& k)
const
239 return this->member() (
extract (e.value), k);
243 bool operator() (Key
const& k,
element const& e)
const
248 bool operator() (
element const& e, Key
const& k)
const
260 return this->member();
265 return this->member();
269 using list_type =
typename boost::intrusive::make_list <element,
270 boost::intrusive::constant_time_size <false>>::type;
274 typename boost::intrusive::make_unordered_multiset <element,
275 boost::intrusive::constant_time_size <true>,
276 boost::intrusive::hash <ValueHash>,
277 boost::intrusive::equal <KeyValueEqual>,
278 boost::intrusive::cache_begin <true>
280 typename boost::intrusive::make_unordered_set <element,
281 boost::intrusive::constant_time_size <true>,
282 boost::intrusive::hash <ValueHash>,
283 boost::intrusive::equal <KeyValueEqual>,
284 boost::intrusive::cache_begin <true>
292 Allocator>::template rebind_alloc <element>;
297 Allocator>::template rebind_alloc <element>;
323 KeyEqual
const& keyEqual)
331 Allocator
const& alloc_)
340 KeyEqual
const& keyEqual)
350 Allocator
const& alloc_)
359 KeyEqual
const& keyEqual,
360 Allocator
const& alloc_)
370 KeyEqual
const& keyEqual,
371 Allocator
const& alloc_)
384 select_on_container_copy_construction (
427 key_eq() = std::move (other.key_eq());
428 alloc() = std::move (other.alloc());
494 template rebind_alloc <bucket_type>>;
501 cont_type::suggested_upper_bucket_count (0));
509 cont_type::suggested_upper_bucket_count (0));
538 template <
class Container>
573 template <
class Container>
577 cont_type::suggested_upper_bucket_count (n));
586 template <
class... Args>
598 operator()(element* p)
607 p.
get(),
clock().now(), std::forward <Args> (args)...);
640 typename cont_type::iterator>;
642 typename cont_type::iterator>;
645 typename cont_type::local_iterator>;
647 typename cont_type::local_iterator>;
664 ! IsMap,
typename list_type::iterator>;
666 true,
typename list_type::iterator>;
668 ! IsMap,
typename list_type::reverse_iterator>;
670 true,
typename list_type::reverse_iterator>;
735 "must be standard layout");
736 return list.iterator_to (*
reinterpret_cast <element*
>(
744 "must be standard layout");
745 return list.iterator_to (*
reinterpret_cast <element const*
>(
746 reinterpret_cast<uint8_t const*
>(&value)-((
std::size_t)
778 Allocator
const& alloc);
781 Hash
const& hash, KeyEqual
const&
key_eq);
784 Hash
const& hash, Allocator
const& alloc);
787 KeyEqual
const&
key_eq, Allocator
const& alloc);
791 Allocator
const& alloc);
793 template <
class InputIt>
797 template <
class InputIt>
801 template <
class InputIt>
805 template <
class InputIt>
809 template <
class InputIt>
813 template <
class InputIt>
817 template <
class InputIt>
820 Allocator
const& alloc);
822 template <
class InputIt>
825 Allocator
const& alloc);
830 Allocator
const& alloc);
835 Allocator
const& alloc);
860 Allocator
const& alloc);
893 bool maybe_multi = IsMulti,
894 bool maybe_map = IsMap,
901 bool maybe_multi = IsMulti,
902 bool maybe_map = IsMap,
905 at (K
const& k)
const;
908 bool maybe_multi = IsMulti,
909 bool maybe_map = IsMap,
915 bool maybe_multi = IsMulti,
916 bool maybe_map = IsMap,
967 "must be standard layout");
968 return m_cont.iterator_to (*
reinterpret_cast <element*
>(
977 "must be standard layout");
978 return m_cont.iterator_to (*
reinterpret_cast <element const*
>(
979 reinterpret_cast<uint8_t const*
>(&value)-((
std::size_t)
1013 template <
bool maybe_multi = IsMulti>
1020 template <
bool maybe_multi = IsMulti>
1027 template <
bool maybe_multi = IsMulti,
bool maybe_map = IsMap>
1034 template <
bool maybe_multi = IsMulti,
bool maybe_map = IsMap>
1041 template <
bool maybe_multi = IsMulti>
1048 return insert (value).first;
1052 template <
bool maybe_multi = IsMulti>
1063 template <
bool maybe_multi = IsMulti>
1070 return insert (std::move (value)).first;
1074 template <
bool maybe_multi = IsMulti>
1081 return insert (std::move (value));
1087 bool maybe_map = IsMap
1097 return emplace (std::forward <P> (value));
1103 bool maybe_map = IsMap
1116 template <
class InputIt>
1121 InputIt>::iterator_category());
1131 template <
bool maybe_multi = IsMulti,
class... Args>
1138 template <
bool maybe_multi = IsMulti,
class... Args>
1145 template <
bool maybe_multi = IsMulti,
class... Args>
1152 template <
bool maybe_multi = IsMulti,
class... Args>
1159 return emplace <maybe_multi> (
1160 std::forward <Args> (args)...);
1163 template <
bool is_const,
class Iterator,
class Base>
1166 is_const, Iterator, Base> pos);
1168 template <
bool is_const,
class Iterator,
class Base>
1171 is_const, Iterator, Base> first,
1173 is_const, Iterator, Base> last);
1177 erase (K
const& k) ->
1183 template <
bool is_const,
class Iterator,
class Base>
1186 is_const, Iterator, Base> pos)
1193 touch (K
const& k) ->
1236 auto const r (
m_cont.equal_range (k,
1248 auto const r (
m_cont.equal_range (k,
1293 return m_cont.bucket_count();
1303 return m_cont.bucket_size (n);
1322 static_cast <float> (
m_cont.bucket_count());
1378 class OtherDuration,
1380 class OtherAllocator,
1381 bool maybe_multi = IsMulti
1386 OtherKey, OtherT, OtherDuration, OtherHash, KeyEqual,
1387 OtherAllocator>
const& other)
const;
1393 class OtherDuration,
1395 class OtherAllocator,
1396 bool maybe_multi = IsMulti
1401 OtherKey, OtherT, OtherDuration, OtherHash, KeyEqual,
1402 OtherAllocator>
const& other)
const;
1409 class OtherDuration,
1411 class OtherAllocator
1415 OtherKey, OtherT, OtherDuration, OtherHash, KeyEqual,
1416 OtherAllocator>
const& other)
const
1425 return size() + additional >
1438 template <
bool maybe_multi = IsMulti>
1445 template <
bool maybe_multi = IsMulti>
1451 template <
class InputIt>
1455 for (; first != last; ++first)
1459 template <
class InputIt>
1464 for (; first != last; ++first)
1468 template <
class InputIt>
1478 template <
bool is_const,
class Iterator,
class Base>
1481 is_const, Iterator, Base> pos,
1484 auto& e (*pos.iterator());
1491 Allocator>::propagate_on_container_swap::value>
1501 Allocator>::propagate_on_container_swap::value>
1517 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1518 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1520 Hash, KeyEqual, Allocator>
::
1525 std::cref (m_config.value_hash()),
1526 std::cref (m_config.key_value_equal()))
1530 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1531 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1533 Hash, KeyEqual, Allocator>
::
1537 : m_config (clock, hash)
1539 std::cref (m_config.value_hash()),
1540 std::cref (m_config.key_value_equal()))
1544 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1545 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1547 Hash, KeyEqual, Allocator>
::
1550 KeyEqual
const& key_eq)
1551 : m_config (clock, key_eq)
1553 std::cref (m_config.value_hash()),
1554 std::cref (m_config.key_value_equal()))
1558 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1559 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1561 Hash, KeyEqual, Allocator>
::
1564 Allocator
const& alloc)
1565 : m_config (clock, alloc)
1568 std::cref (m_config.value_hash()),
1569 std::cref (m_config.key_value_equal()))
1573 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1574 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1576 Hash, KeyEqual, Allocator>
::
1580 KeyEqual
const& key_eq)
1581 : m_config (clock, hash, key_eq)
1583 std::cref (m_config.value_hash()),
1584 std::cref (m_config.key_value_equal()))
1588 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1589 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1591 Hash, KeyEqual, Allocator>
::
1595 Allocator
const& alloc)
1596 : m_config (clock, hash, alloc)
1599 std::cref (m_config.value_hash()),
1600 std::cref (m_config.key_value_equal()))
1604 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1605 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1607 Hash, KeyEqual, Allocator>
::
1610 KeyEqual
const& key_eq,
1611 Allocator
const& alloc)
1612 : m_config (clock, key_eq, alloc)
1615 std::cref (m_config.value_hash()),
1616 std::cref (m_config.key_value_equal()))
1620 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1621 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1623 Hash, KeyEqual, Allocator>
::
1627 KeyEqual
const& key_eq,
1628 Allocator
const& alloc)
1629 : m_config (clock, hash, key_eq, alloc)
1632 std::cref (m_config.value_hash()),
1633 std::cref (m_config.key_value_equal()))
1637 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1638 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1639 template <
class InputIt>
1641 Hash, KeyEqual, Allocator>
::
1646 std::cref (m_config.value_hash()),
1647 std::cref (m_config.key_value_equal()))
1649 insert (first, last);
1652 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1653 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1654 template <
class InputIt>
1656 Hash, KeyEqual, Allocator>
::
1660 : m_config (clock, hash)
1662 std::cref (m_config.value_hash()),
1663 std::cref (m_config.key_value_equal()))
1665 insert (first, last);
1668 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1669 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1670 template <
class InputIt>
1672 Hash, KeyEqual, Allocator>
::
1675 KeyEqual
const& key_eq)
1676 : m_config (clock, key_eq)
1678 std::cref (m_config.value_hash()),
1679 std::cref (m_config.key_value_equal()))
1681 insert (first, last);
1684 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1685 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1686 template <
class InputIt>
1688 Hash, KeyEqual, Allocator>
::
1691 Allocator
const& alloc)
1692 : m_config (clock, alloc)
1695 std::cref (m_config.value_hash()),
1696 std::cref (m_config.key_value_equal()))
1698 insert (first, last);
1701 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1702 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1703 template <
class InputIt>
1705 Hash, KeyEqual, Allocator>
::
1709 KeyEqual
const& key_eq)
1710 : m_config (clock, hash, key_eq)
1712 std::cref (m_config.value_hash()),
1713 std::cref (m_config.key_value_equal()))
1715 insert (first, last);
1718 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1719 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1720 template <
class InputIt>
1722 Hash, KeyEqual, Allocator>
::
1726 Allocator
const& alloc)
1727 : m_config (clock, hash, alloc)
1730 std::cref (m_config.value_hash()),
1731 std::cref (m_config.key_value_equal()))
1733 insert (first, last);
1736 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1737 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1738 template <
class InputIt>
1740 Hash, KeyEqual, Allocator>
::
1743 KeyEqual
const& key_eq,
1744 Allocator
const& alloc)
1745 : m_config (clock, key_eq, alloc)
1748 std::cref (m_config.value_hash()),
1749 std::cref (m_config.key_value_equal()))
1751 insert (first, last);
1754 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1755 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1756 template <
class InputIt>
1758 Hash, KeyEqual, Allocator>
::
1762 KeyEqual
const& key_eq,
1763 Allocator
const& alloc)
1764 : m_config (clock, hash, key_eq, alloc)
1767 std::cref (m_config.value_hash()),
1768 std::cref (m_config.key_value_equal()))
1770 insert (first, last);
1773 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1774 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1776 Hash, KeyEqual, Allocator>
::
1778 : m_config (other.m_config)
1779 , m_buck (m_config.alloc())
1781 std::cref (m_config.value_hash()),
1782 std::cref (m_config.key_value_equal()))
1787 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1788 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1790 Hash, KeyEqual, Allocator>
::
1792 Allocator
const& alloc)
1793 : m_config (other.m_config, alloc)
1796 std::cref (m_config.value_hash()),
1797 std::cref (m_config.key_value_equal()))
1802 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1803 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1805 Hash, KeyEqual, Allocator>
::
1807 : m_config (
std::move (other.m_config))
1808 , m_buck (
std::move (other.m_buck))
1809 , m_cont (
std::move (other.m_cont))
1811 chronological.list = std::move (other.chronological.list);
1814 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1815 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1817 Hash, KeyEqual, Allocator>
::
1819 Allocator
const& alloc)
1820 : m_config (
std::move (other.m_config), alloc)
1823 std::cref (m_config.value_hash()),
1824 std::cref (m_config.key_value_equal()))
1826 insert (other.cbegin(), other.cend());
1830 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1831 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1833 Hash, KeyEqual, Allocator>
::
1838 std::cref (m_config.value_hash()),
1839 std::cref (m_config.key_value_equal()))
1844 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1845 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1847 Hash, KeyEqual, Allocator>
::
1851 : m_config (clock, hash)
1853 std::cref (m_config.value_hash()),
1854 std::cref (m_config.key_value_equal()))
1859 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1860 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1862 Hash, KeyEqual, Allocator>
::
1865 KeyEqual
const& key_eq)
1866 : m_config (clock, key_eq)
1868 std::cref (m_config.value_hash()),
1869 std::cref (m_config.key_value_equal()))
1874 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1875 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1877 Hash, KeyEqual, Allocator>
::
1880 Allocator
const& alloc)
1881 : m_config (clock, alloc)
1884 std::cref (m_config.value_hash()),
1885 std::cref (m_config.key_value_equal()))
1890 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1891 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1893 Hash, KeyEqual, Allocator>
::
1897 KeyEqual
const& key_eq)
1898 : m_config (clock, hash, key_eq)
1900 std::cref (m_config.value_hash()),
1901 std::cref (m_config.key_value_equal()))
1906 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1907 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1909 Hash, KeyEqual, Allocator>
::
1913 Allocator
const& alloc)
1914 : m_config (clock, hash, alloc)
1917 std::cref (m_config.value_hash()),
1918 std::cref (m_config.key_value_equal()))
1923 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1924 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1926 Hash, KeyEqual, Allocator>
::
1929 KeyEqual
const& key_eq,
1930 Allocator
const& alloc)
1931 : m_config (clock, key_eq, alloc)
1934 std::cref (m_config.value_hash()),
1935 std::cref (m_config.key_value_equal()))
1940 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1941 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1943 Hash, KeyEqual, Allocator>
::
1947 KeyEqual
const& key_eq,
1948 Allocator
const& alloc)
1949 : m_config (clock, hash, key_eq, alloc)
1952 std::cref (m_config.value_hash()),
1953 std::cref (m_config.key_value_equal()))
1958 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1959 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1961 Hash, KeyEqual, Allocator>::
1962 ~aged_unordered_container()
1967 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1968 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1971 Hash, KeyEqual, Allocator>::
1979 m_config = other.m_config;
1980 m_buck = Buckets (m_config.alloc());
1982 insert_unchecked (other.begin(), other.end());
1987 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
1988 class Clock,
class Hash,
class KeyEqual,
class Allocator>
1991 Hash, KeyEqual, Allocator>::
1997 m_config = std::move (other.m_config);
1998 m_buck = Buckets (m_config.alloc());
2000 insert_unchecked (other.begin(), other.end());
2005 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2006 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2009 Hash, KeyEqual, Allocator>::
2020 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2021 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2022 template <
class K,
bool maybe_multi,
bool maybe_map,
class>
2025 Hash, KeyEqual, Allocator>::
2028 auto const iter (m_cont.find (k,
2030 std::cref (m_config.key_value_equal())));
2031 if (iter == m_cont.end())
2033 return iter->value.second;
2036 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2037 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2038 template <
class K,
bool maybe_multi,
bool maybe_map,
class>
2041 Hash, KeyEqual, Allocator>::
2042 at (K
const& k)
const
2044 auto const iter (m_cont.find (k,
2046 std::cref (m_config.key_value_equal())));
2047 if (iter == m_cont.end())
2049 return iter->value.second;
2052 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2053 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2054 template <
bool maybe_multi,
bool maybe_map,
class>
2057 Hash, KeyEqual, Allocator>::
2058 operator[] (Key
const& key)
2061 typename cont_type::insert_commit_data d;
2062 auto const result (m_cont.insert_check (key,
2064 std::cref (m_config.key_value_equal()), d));
2067 element*
const p (new_element (
2068 std::piecewise_construct,
2071 m_cont.insert_commit (*p, d);
2072 chronological.list.push_back (*p);
2073 return p->value.second;
2075 return result.first->value.second;
2078 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2079 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2080 template <
bool maybe_multi,
bool maybe_map,
class>
2083 Hash, KeyEqual, Allocator>::
2084 operator[] (Key&& key)
2087 typename cont_type::insert_commit_data d;
2088 auto const result (m_cont.insert_check (key,
2090 std::cref (m_config.key_value_equal()), d));
2093 element*
const p (new_element (
2094 std::piecewise_construct,
2097 m_cont.insert_commit (*p, d);
2098 chronological.list.push_back (*p);
2099 return p->value.second;
2101 return result.first->value.second;
2106 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2107 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2110 Hash, KeyEqual, Allocator>::
2113 for (
auto iter (chronological.list.begin());
2114 iter != chronological.list.end();)
2115 unlink_and_delete_element (&*iter++);
2116 chronological.list.clear();
2122 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2123 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2124 template <
bool maybe_multi>
2127 Hash, KeyEqual, Allocator>::
2133 typename cont_type::insert_commit_data d;
2134 auto const result (m_cont.insert_check (extract (value),
2136 std::cref (m_config.key_value_equal()), d));
2139 element*
const p (new_element (value));
2140 auto const iter (m_cont.insert_commit (*p, d));
2141 chronological.list.push_back (*p);
2148 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2149 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2150 template <
bool maybe_multi>
2153 Hash, KeyEqual, Allocator>::
2154 insert (value_type
const& value) ->
2159 element*
const p (new_element (value));
2160 chronological.list.push_back (*p);
2161 auto const iter (m_cont.insert (*p));
2162 return iterator (iter);
2166 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2167 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2168 template <
bool maybe_multi,
bool maybe_map>
2170 aged_unordered_container <IsMulti, IsMap, Key, T, Clock,
2171 Hash, KeyEqual, Allocator>::
2177 typename cont_type::insert_commit_data d;
2178 auto const result (m_cont.insert_check (extract (value),
2180 std::cref (m_config.key_value_equal()), d));
2183 element*
const p (new_element (std::move (value)));
2184 auto const iter (m_cont.insert_commit (*p, d));
2185 chronological.list.push_back (*p);
2192 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2193 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2194 template <
bool maybe_multi,
bool maybe_map>
2197 Hash, KeyEqual, Allocator>::
2198 insert (value_type&& value) ->
2203 element*
const p (new_element (std::move (value)));
2204 chronological.list.push_back (*p);
2205 auto const iter (m_cont.insert (*p));
2206 return iterator (iter);
2209 #if 1 // Use insert() instead of insert_check() insert_commit()
2211 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2212 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2213 template <
bool maybe_multi,
class... Args>
2215 aged_unordered_container <IsMulti, IsMap, Key, T, Clock,
2216 Hash, KeyEqual, Allocator>::
2217 emplace (Args&&... args) ->
2224 element*
const p (new_element (std::forward <Args> (args)...));
2225 auto const result (m_cont.insert (*p));
2228 chronological.list.push_back (*p);
2234 #else // As original, use insert_check() / insert_commit () pair.
2236 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2237 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2238 template <
bool maybe_multi,
class... Args>
2241 Hash, KeyEqual, Allocator>::
2242 emplace (Args&&... args) ->
2249 element*
const p (new_element (
2250 std::forward <Args> (args)...));
2251 typename cont_type::insert_commit_data d;
2252 auto const result (m_cont.insert_check (extract (p->value),
2254 std::cref (m_config.key_value_equal()), d));
2257 auto const iter (m_cont.insert_commit (*p, d));
2258 chronological.list.push_back (*p);
2267 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2268 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2269 template <
bool maybe_multi,
class... Args>
2271 aged_unordered_container <IsMulti, IsMap, Key, T, Clock,
2272 Hash, KeyEqual, Allocator>::
2273 emplace (Args&&... args) ->
2278 element*
const p (new_element (
2279 std::forward <Args> (args)...));
2280 chronological.list.push_back (*p);
2281 auto const iter (m_cont.insert (*p));
2282 return iterator (iter);
2286 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2287 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2288 template <
bool maybe_multi,
class... Args>
2290 aged_unordered_container <IsMulti, IsMap, Key, T, Clock,
2291 Hash, KeyEqual, Allocator>::
2299 element*
const p (new_element (
2300 std::forward <Args> (args)...));
2301 typename cont_type::insert_commit_data d;
2302 auto const result (m_cont.insert_check (extract (p->value),
2304 std::cref (m_config.key_value_equal()), d));
2307 auto const iter (m_cont.insert_commit (*p, d));
2308 chronological.list.push_back (*p);
2315 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2316 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2317 template <
bool is_const,
class Iterator,
class Base>
2320 Hash, KeyEqual, Allocator>::
2322 is_const, Iterator, Base> pos)
2324 unlink_and_delete_element(&*((pos++).
iterator()));
2326 false, Iterator, Base> (pos.iterator());
2329 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2330 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2331 template <
bool is_const,
class Iterator,
class Base>
2334 Hash, KeyEqual, Allocator>::
2336 is_const, Iterator, Base> first,
2338 is_const, Iterator, Base> last)
2340 for (; first != last;)
2341 unlink_and_delete_element(&*((first++).
iterator()));
2344 false, Iterator, Base> (first.iterator());
2347 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2348 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2352 Hash, KeyEqual, Allocator>::
2353 erase (K
const& k) ->
2356 auto iter (m_cont.find (k,
std::cref (m_config.hash_function()),
2357 std::cref (m_config.key_value_equal())));
2358 if (iter == m_cont.end())
2365 m_config (*p, extract (iter->value)));
2366 unlink_and_delete_element (p);
2374 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2375 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2378 Hash, KeyEqual, Allocator>::
2382 std::swap (chronological, other.chronological);
2386 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2387 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2391 Hash, KeyEqual, Allocator>::
2392 touch (K
const& k) ->
2395 auto const now (clock().now());
2397 auto const range (equal_range (k));
2398 for (
auto iter : range)
2406 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2407 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2412 class OtherDuration,
2414 class OtherAllocator,
2419 IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::
2422 OtherKey, OtherT, OtherDuration, OtherHash, KeyEqual,
2423 OtherAllocator>
const& other)
const
2425 if (size() != other.size())
2427 for (
auto iter (cbegin()), last (cend()), olast (other.cend());
2428 iter != last; ++iter)
2430 auto oiter (other.find (extract (*iter)));
2437 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2438 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2443 class OtherDuration,
2445 class OtherAllocator,
2450 IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::
2453 OtherKey, OtherT, OtherDuration, OtherHash, KeyEqual,
2454 OtherAllocator>
const& other)
const
2456 if (size() != other.size())
2459 for (
auto iter (cbegin()), last (cend()); iter != last;)
2461 auto const& k (extract (*iter));
2462 auto const eq (equal_range (k));
2463 auto const oeq (other.equal_range (k));
2464 #if BEAST_NO_CXX14_IS_PERMUTATION
2471 eq.second, oeq.first, oeq.second))
2482 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2483 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2484 template <
bool maybe_multi>
2487 Hash, KeyEqual, Allocator>::
2492 typename cont_type::insert_commit_data d;
2493 auto const result (m_cont.insert_check (extract (value),
2495 std::cref (m_config.key_value_equal()), d));
2498 element*
const p (new_element (value));
2499 auto const iter (m_cont.insert_commit (*p, d));
2500 chronological.list.push_back (*p);
2507 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2508 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2509 template <
bool maybe_multi>
2512 Hash, KeyEqual, Allocator>::
2513 insert_unchecked (value_type
const& value) ->
2517 element*
const p (new_element (value));
2518 chronological.list.push_back (*p);
2519 auto const iter (m_cont.insert (*p));
2520 return iterator (iter);
2529 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2530 class Clock,
class Hash,
class KeyEqual,
class Allocator>
2532 IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>>
2540 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
class Clock,
2541 class Hash,
class KeyEqual,
class Allocator>
2544 Key, T, Clock, Hash, KeyEqual, Allocator>& lhs,
2546 Key, T, Clock, Hash, KeyEqual, Allocator>& rhs) noexcept
2552 template <
bool IsMulti,
bool IsMap,
class Key,
class T,
2553 class Clock,
class Hash,
class KeyEqual,
class Allocator,
2554 class Rep,
class Period>
2556 IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>& c,
2560 auto const expired (c.clock().now() - age);
2561 for (
auto iter (c.chronological.cbegin());
2562 iter != c.chronological.cend() &&
2563 iter.when() <= expired;)
2565 iter = c.erase (iter);