concurrent_node_map.hpp 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  1. /* Fast open-addressing, node-based concurrent hashmap.
  2. *
  3. * Copyright 2023 Christian Mazakas.
  4. * Copyright 2023-2024 Joaquin M Lopez Munoz.
  5. * Distributed under the Boost Software License, Version 1.0.
  6. * (See accompanying file LICENSE_1_0.txt or copy at
  7. * http://www.boost.org/LICENSE_1_0.txt)
  8. *
  9. * See https://www.boost.org/libs/unordered for library home page.
  10. */
  11. #ifndef BOOST_UNORDERED_CONCURRENT_NODE_MAP_HPP
  12. #define BOOST_UNORDERED_CONCURRENT_NODE_MAP_HPP
  13. #include <boost/unordered/concurrent_node_map_fwd.hpp>
  14. #include <boost/unordered/detail/concurrent_static_asserts.hpp>
  15. #include <boost/unordered/detail/foa/concurrent_table.hpp>
  16. #include <boost/unordered/detail/foa/element_type.hpp>
  17. #include <boost/unordered/detail/foa/node_map_handle.hpp>
  18. #include <boost/unordered/detail/foa/node_map_types.hpp>
  19. #include <boost/unordered/detail/type_traits.hpp>
  20. #include <boost/unordered/unordered_node_map_fwd.hpp>
  21. #include <boost/container_hash/hash.hpp>
  22. #include <boost/core/allocator_access.hpp>
  23. #include <boost/core/serialization.hpp>
  24. #include <type_traits>
  25. namespace boost {
  26. namespace unordered {
  27. template <class Key, class T, class Hash, class Pred, class Allocator>
  28. class concurrent_node_map
  29. {
  30. private:
  31. template <class Key2, class T2, class Hash2, class Pred2,
  32. class Allocator2>
  33. friend class concurrent_node_map;
  34. template <class Key2, class T2, class Hash2, class Pred2,
  35. class Allocator2>
  36. friend class unordered_node_map;
  37. using type_policy = detail::foa::node_map_types<Key, T,
  38. typename boost::allocator_void_pointer<Allocator>::type>;
  39. using table_type =
  40. detail::foa::concurrent_table<type_policy, Hash, Pred, Allocator>;
  41. table_type table_;
  42. template <class K, class V, class H, class KE, class A>
  43. bool friend operator==(concurrent_node_map<K, V, H, KE, A> const& lhs,
  44. concurrent_node_map<K, V, H, KE, A> const& rhs);
  45. template <class K, class V, class H, class KE, class A, class Predicate>
  46. friend typename concurrent_node_map<K, V, H, KE, A>::size_type erase_if(
  47. concurrent_node_map<K, V, H, KE, A>& set, Predicate pred);
  48. template<class Archive, class K, class V, class H, class KE, class A>
  49. friend void serialize(
  50. Archive& ar, concurrent_node_map<K, V, H, KE, A>& c,
  51. unsigned int version);
  52. public:
  53. using key_type = Key;
  54. using mapped_type = T;
  55. using value_type = typename type_policy::value_type;
  56. using init_type = typename type_policy::init_type;
  57. using size_type = std::size_t;
  58. using difference_type = std::ptrdiff_t;
  59. using hasher = typename boost::unordered::detail::type_identity<Hash>::type;
  60. using key_equal = typename boost::unordered::detail::type_identity<Pred>::type;
  61. using allocator_type = typename boost::unordered::detail::type_identity<Allocator>::type;
  62. using reference = value_type&;
  63. using const_reference = value_type const&;
  64. using pointer = typename boost::allocator_pointer<allocator_type>::type;
  65. using const_pointer =
  66. typename boost::allocator_const_pointer<allocator_type>::type;
  67. using node_type = detail::foa::node_map_handle<type_policy,
  68. typename boost::allocator_rebind<Allocator,
  69. typename type_policy::value_type>::type>;
  70. using insert_return_type =
  71. detail::foa::iteratorless_insert_return_type<node_type>;
  72. static constexpr size_type bulk_visit_size = table_type::bulk_visit_size;
  73. #if defined(BOOST_UNORDERED_ENABLE_STATS)
  74. using stats = typename table_type::stats;
  75. #endif
  76. concurrent_node_map()
  77. : concurrent_node_map(detail::foa::default_bucket_count)
  78. {
  79. }
  80. explicit concurrent_node_map(size_type n, const hasher& hf = hasher(),
  81. const key_equal& eql = key_equal(),
  82. const allocator_type& a = allocator_type())
  83. : table_(n, hf, eql, a)
  84. {
  85. }
  86. template <class InputIterator>
  87. concurrent_node_map(InputIterator f, InputIterator l,
  88. size_type n = detail::foa::default_bucket_count,
  89. const hasher& hf = hasher(), const key_equal& eql = key_equal(),
  90. const allocator_type& a = allocator_type())
  91. : table_(n, hf, eql, a)
  92. {
  93. this->insert(f, l);
  94. }
  95. concurrent_node_map(concurrent_node_map const& rhs)
  96. : table_(rhs.table_,
  97. boost::allocator_select_on_container_copy_construction(
  98. rhs.get_allocator()))
  99. {
  100. }
  101. concurrent_node_map(concurrent_node_map&& rhs)
  102. : table_(std::move(rhs.table_))
  103. {
  104. }
  105. template <class InputIterator>
  106. concurrent_node_map(
  107. InputIterator f, InputIterator l, allocator_type const& a)
  108. : concurrent_node_map(f, l, 0, hasher(), key_equal(), a)
  109. {
  110. }
  111. explicit concurrent_node_map(allocator_type const& a)
  112. : table_(detail::foa::default_bucket_count, hasher(), key_equal(), a)
  113. {
  114. }
  115. concurrent_node_map(
  116. concurrent_node_map const& rhs, allocator_type const& a)
  117. : table_(rhs.table_, a)
  118. {
  119. }
  120. concurrent_node_map(concurrent_node_map&& rhs, allocator_type const& a)
  121. : table_(std::move(rhs.table_), a)
  122. {
  123. }
  124. concurrent_node_map(std::initializer_list<value_type> il,
  125. size_type n = detail::foa::default_bucket_count,
  126. const hasher& hf = hasher(), const key_equal& eql = key_equal(),
  127. const allocator_type& a = allocator_type())
  128. : concurrent_node_map(n, hf, eql, a)
  129. {
  130. this->insert(il.begin(), il.end());
  131. }
  132. concurrent_node_map(size_type n, const allocator_type& a)
  133. : concurrent_node_map(n, hasher(), key_equal(), a)
  134. {
  135. }
  136. concurrent_node_map(
  137. size_type n, const hasher& hf, const allocator_type& a)
  138. : concurrent_node_map(n, hf, key_equal(), a)
  139. {
  140. }
  141. template <typename InputIterator>
  142. concurrent_node_map(
  143. InputIterator f, InputIterator l, size_type n, const allocator_type& a)
  144. : concurrent_node_map(f, l, n, hasher(), key_equal(), a)
  145. {
  146. }
  147. template <typename InputIterator>
  148. concurrent_node_map(InputIterator f, InputIterator l, size_type n,
  149. const hasher& hf, const allocator_type& a)
  150. : concurrent_node_map(f, l, n, hf, key_equal(), a)
  151. {
  152. }
  153. concurrent_node_map(
  154. std::initializer_list<value_type> il, const allocator_type& a)
  155. : concurrent_node_map(
  156. il, detail::foa::default_bucket_count, hasher(), key_equal(), a)
  157. {
  158. }
  159. concurrent_node_map(std::initializer_list<value_type> il, size_type n,
  160. const allocator_type& a)
  161. : concurrent_node_map(il, n, hasher(), key_equal(), a)
  162. {
  163. }
  164. concurrent_node_map(std::initializer_list<value_type> il, size_type n,
  165. const hasher& hf, const allocator_type& a)
  166. : concurrent_node_map(il, n, hf, key_equal(), a)
  167. {
  168. }
  169. template <bool avoid_explicit_instantiation = true>
  170. concurrent_node_map(
  171. unordered_node_map<Key, T, Hash, Pred, Allocator>&& other)
  172. : table_(std::move(other.table_))
  173. {
  174. }
  175. ~concurrent_node_map() = default;
  176. concurrent_node_map& operator=(concurrent_node_map const& rhs)
  177. {
  178. table_ = rhs.table_;
  179. return *this;
  180. }
  181. concurrent_node_map& operator=(concurrent_node_map&& rhs) noexcept(
  182. noexcept(std::declval<table_type&>() = std::declval<table_type&&>()))
  183. {
  184. table_ = std::move(rhs.table_);
  185. return *this;
  186. }
  187. concurrent_node_map& operator=(std::initializer_list<value_type> ilist)
  188. {
  189. table_ = ilist;
  190. return *this;
  191. }
  192. /// Capacity
  193. ///
  194. size_type size() const noexcept { return table_.size(); }
  195. size_type max_size() const noexcept { return table_.max_size(); }
  196. BOOST_ATTRIBUTE_NODISCARD bool empty() const noexcept
  197. {
  198. return size() == 0;
  199. }
  200. template <class F>
  201. BOOST_FORCEINLINE size_type visit(key_type const& k, F f)
  202. {
  203. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F)
  204. return table_.visit(k, f);
  205. }
  206. template <class F>
  207. BOOST_FORCEINLINE size_type visit(key_type const& k, F f) const
  208. {
  209. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  210. return table_.visit(k, f);
  211. }
  212. template <class F>
  213. BOOST_FORCEINLINE size_type cvisit(key_type const& k, F f) const
  214. {
  215. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  216. return table_.visit(k, f);
  217. }
  218. template <class K, class F>
  219. BOOST_FORCEINLINE typename std::enable_if<
  220. detail::are_transparent<K, hasher, key_equal>::value, size_type>::type
  221. visit(K&& k, F f)
  222. {
  223. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F)
  224. return table_.visit(std::forward<K>(k), f);
  225. }
  226. template <class K, class F>
  227. BOOST_FORCEINLINE typename std::enable_if<
  228. detail::are_transparent<K, hasher, key_equal>::value, size_type>::type
  229. visit(K&& k, F f) const
  230. {
  231. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  232. return table_.visit(std::forward<K>(k), f);
  233. }
  234. template <class K, class F>
  235. BOOST_FORCEINLINE typename std::enable_if<
  236. detail::are_transparent<K, hasher, key_equal>::value, size_type>::type
  237. cvisit(K&& k, F f) const
  238. {
  239. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  240. return table_.visit(std::forward<K>(k), f);
  241. }
  242. template<class FwdIterator, class F>
  243. BOOST_FORCEINLINE
  244. size_t visit(FwdIterator first, FwdIterator last, F f)
  245. {
  246. BOOST_UNORDERED_STATIC_ASSERT_BULK_VISIT_ITERATOR(FwdIterator)
  247. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F)
  248. return table_.visit(first, last, f);
  249. }
  250. template<class FwdIterator, class F>
  251. BOOST_FORCEINLINE
  252. size_t visit(FwdIterator first, FwdIterator last, F f) const
  253. {
  254. BOOST_UNORDERED_STATIC_ASSERT_BULK_VISIT_ITERATOR(FwdIterator)
  255. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  256. return table_.visit(first, last, f);
  257. }
  258. template<class FwdIterator, class F>
  259. BOOST_FORCEINLINE
  260. size_t cvisit(FwdIterator first, FwdIterator last, F f) const
  261. {
  262. BOOST_UNORDERED_STATIC_ASSERT_BULK_VISIT_ITERATOR(FwdIterator)
  263. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  264. return table_.visit(first, last, f);
  265. }
  266. template <class F> size_type visit_all(F f)
  267. {
  268. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F)
  269. return table_.visit_all(f);
  270. }
  271. template <class F> size_type visit_all(F f) const
  272. {
  273. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  274. return table_.visit_all(f);
  275. }
  276. template <class F> size_type cvisit_all(F f) const
  277. {
  278. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  279. return table_.cvisit_all(f);
  280. }
  281. #if defined(BOOST_UNORDERED_PARALLEL_ALGORITHMS)
  282. template <class ExecPolicy, class F>
  283. typename std::enable_if<detail::is_execution_policy<ExecPolicy>::value,
  284. void>::type
  285. visit_all(ExecPolicy&& p, F f)
  286. {
  287. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F)
  288. BOOST_UNORDERED_STATIC_ASSERT_EXEC_POLICY(ExecPolicy)
  289. table_.visit_all(p, f);
  290. }
  291. template <class ExecPolicy, class F>
  292. typename std::enable_if<detail::is_execution_policy<ExecPolicy>::value,
  293. void>::type
  294. visit_all(ExecPolicy&& p, F f) const
  295. {
  296. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  297. BOOST_UNORDERED_STATIC_ASSERT_EXEC_POLICY(ExecPolicy)
  298. table_.visit_all(p, f);
  299. }
  300. template <class ExecPolicy, class F>
  301. typename std::enable_if<detail::is_execution_policy<ExecPolicy>::value,
  302. void>::type
  303. cvisit_all(ExecPolicy&& p, F f) const
  304. {
  305. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  306. BOOST_UNORDERED_STATIC_ASSERT_EXEC_POLICY(ExecPolicy)
  307. table_.cvisit_all(p, f);
  308. }
  309. #endif
  310. template <class F> bool visit_while(F f)
  311. {
  312. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F)
  313. return table_.visit_while(f);
  314. }
  315. template <class F> bool visit_while(F f) const
  316. {
  317. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  318. return table_.visit_while(f);
  319. }
  320. template <class F> bool cvisit_while(F f) const
  321. {
  322. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  323. return table_.cvisit_while(f);
  324. }
  325. #if defined(BOOST_UNORDERED_PARALLEL_ALGORITHMS)
  326. template <class ExecPolicy, class F>
  327. typename std::enable_if<detail::is_execution_policy<ExecPolicy>::value,
  328. bool>::type
  329. visit_while(ExecPolicy&& p, F f)
  330. {
  331. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F)
  332. BOOST_UNORDERED_STATIC_ASSERT_EXEC_POLICY(ExecPolicy)
  333. return table_.visit_while(p, f);
  334. }
  335. template <class ExecPolicy, class F>
  336. typename std::enable_if<detail::is_execution_policy<ExecPolicy>::value,
  337. bool>::type
  338. visit_while(ExecPolicy&& p, F f) const
  339. {
  340. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  341. BOOST_UNORDERED_STATIC_ASSERT_EXEC_POLICY(ExecPolicy)
  342. return table_.visit_while(p, f);
  343. }
  344. template <class ExecPolicy, class F>
  345. typename std::enable_if<detail::is_execution_policy<ExecPolicy>::value,
  346. bool>::type
  347. cvisit_while(ExecPolicy&& p, F f) const
  348. {
  349. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  350. BOOST_UNORDERED_STATIC_ASSERT_EXEC_POLICY(ExecPolicy)
  351. return table_.cvisit_while(p, f);
  352. }
  353. #endif
  354. /// Modifiers
  355. ///
  356. template <class Ty>
  357. BOOST_FORCEINLINE auto insert(Ty&& value)
  358. -> decltype(table_.insert(std::forward<Ty>(value)))
  359. {
  360. return table_.insert(std::forward<Ty>(value));
  361. }
  362. BOOST_FORCEINLINE bool insert(init_type&& obj)
  363. {
  364. return table_.insert(std::move(obj));
  365. }
  366. template <class InputIterator>
  367. size_type insert(InputIterator begin, InputIterator end)
  368. {
  369. size_type count_elements = 0;
  370. for (auto pos = begin; pos != end; ++pos, ++count_elements) {
  371. table_.emplace(*pos);
  372. }
  373. return count_elements;
  374. }
  375. size_type insert(std::initializer_list<value_type> ilist)
  376. {
  377. return this->insert(ilist.begin(), ilist.end());
  378. }
  379. insert_return_type insert(node_type&& nh)
  380. {
  381. using access = detail::foa::node_handle_access;
  382. if (nh.empty()) {
  383. return {false, node_type{}};
  384. }
  385. // Caveat: get_allocator() incurs synchronization (not cheap)
  386. BOOST_ASSERT(get_allocator() == nh.get_allocator());
  387. if (table_.insert(std::move(access::element(nh)))) {
  388. access::reset(nh);
  389. return {true, node_type{}};
  390. } else {
  391. return {false, std::move(nh)};
  392. }
  393. }
  394. template <class M>
  395. BOOST_FORCEINLINE bool insert_or_assign(key_type const& k, M&& obj)
  396. {
  397. return table_.try_emplace_or_visit(k, std::forward<M>(obj),
  398. [&](value_type& m) { m.second = std::forward<M>(obj); });
  399. }
  400. template <class M>
  401. BOOST_FORCEINLINE bool insert_or_assign(key_type&& k, M&& obj)
  402. {
  403. return table_.try_emplace_or_visit(std::move(k), std::forward<M>(obj),
  404. [&](value_type& m) { m.second = std::forward<M>(obj); });
  405. }
  406. template <class K, class M>
  407. BOOST_FORCEINLINE typename std::enable_if<
  408. detail::are_transparent<K, hasher, key_equal>::value, bool>::type
  409. insert_or_assign(K&& k, M&& obj)
  410. {
  411. return table_.try_emplace_or_visit(std::forward<K>(k),
  412. std::forward<M>(obj),
  413. [&](value_type& m) { m.second = std::forward<M>(obj); });
  414. }
  415. template <class Ty, class F>
  416. BOOST_FORCEINLINE auto insert_or_visit(Ty&& value, F f)
  417. -> decltype(table_.insert_or_visit(std::forward<Ty>(value), f))
  418. {
  419. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F)
  420. return table_.insert_or_visit(std::forward<Ty>(value), f);
  421. }
  422. template <class F>
  423. BOOST_FORCEINLINE bool insert_or_visit(init_type&& obj, F f)
  424. {
  425. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F)
  426. return table_.insert_or_visit(std::move(obj), f);
  427. }
  428. template <class InputIterator, class F>
  429. size_type insert_or_visit(InputIterator first, InputIterator last, F f)
  430. {
  431. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F)
  432. size_type count_elements = 0;
  433. for (; first != last; ++first, ++count_elements) {
  434. table_.emplace_or_visit(*first, f);
  435. }
  436. return count_elements;
  437. }
  438. template <class F>
  439. size_type insert_or_visit(std::initializer_list<value_type> ilist, F f)
  440. {
  441. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F)
  442. return this->insert_or_visit(ilist.begin(), ilist.end(), std::ref(f));
  443. }
  444. template <class F>
  445. insert_return_type insert_or_visit(node_type&& nh, F f)
  446. {
  447. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F)
  448. using access = detail::foa::node_handle_access;
  449. if (nh.empty()) {
  450. return {false, node_type{}};
  451. }
  452. // Caveat: get_allocator() incurs synchronization (not cheap)
  453. BOOST_ASSERT(get_allocator() == nh.get_allocator());
  454. if (table_.insert_or_visit(std::move(access::element(nh)), f)) {
  455. access::reset(nh);
  456. return {true, node_type{}};
  457. } else {
  458. return {false, std::move(nh)};
  459. }
  460. }
  461. template <class Ty, class F>
  462. BOOST_FORCEINLINE auto insert_or_cvisit(Ty&& value, F f)
  463. -> decltype(table_.insert_or_cvisit(std::forward<Ty>(value), f))
  464. {
  465. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  466. return table_.insert_or_cvisit(std::forward<Ty>(value), f);
  467. }
  468. template <class F>
  469. BOOST_FORCEINLINE bool insert_or_cvisit(init_type&& obj, F f)
  470. {
  471. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  472. return table_.insert_or_cvisit(std::move(obj), f);
  473. }
  474. template <class InputIterator, class F>
  475. size_type insert_or_cvisit(InputIterator first, InputIterator last, F f)
  476. {
  477. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  478. size_type count_elements = 0;
  479. for (; first != last; ++first, ++count_elements) {
  480. table_.emplace_or_cvisit(*first, f);
  481. }
  482. return count_elements;
  483. }
  484. template <class F>
  485. size_type insert_or_cvisit(std::initializer_list<value_type> ilist, F f)
  486. {
  487. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  488. return this->insert_or_cvisit(ilist.begin(), ilist.end(), std::ref(f));
  489. }
  490. template <class F>
  491. insert_return_type insert_or_cvisit(node_type&& nh, F f)
  492. {
  493. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
  494. using access = detail::foa::node_handle_access;
  495. if (nh.empty()) {
  496. return {false, node_type{}};
  497. }
  498. // Caveat: get_allocator() incurs synchronization (not cheap)
  499. BOOST_ASSERT(get_allocator() == nh.get_allocator());
  500. if (table_.insert_or_cvisit(std::move(access::element(nh)), f)) {
  501. access::reset(nh);
  502. return {true, node_type{}};
  503. } else {
  504. return {false, std::move(nh)};
  505. }
  506. }
  507. template <class Ty, class F1, class F2>
  508. BOOST_FORCEINLINE auto insert_and_visit(Ty&& value, F1 f1, F2 f2)
  509. -> decltype(table_.insert_and_visit(std::forward<Ty>(value), f1, f2))
  510. {
  511. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F1)
  512. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F2)
  513. return table_.insert_and_visit(std::forward<Ty>(value), f1, f2);
  514. }
  515. template <class F1, class F2>
  516. BOOST_FORCEINLINE bool insert_and_visit(init_type&& obj, F1 f1, F2 f2)
  517. {
  518. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F1)
  519. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F2)
  520. return table_.insert_and_visit(std::move(obj), f1, f2);
  521. }
  522. template <class InputIterator, class F1, class F2>
  523. size_type insert_and_visit(
  524. InputIterator first, InputIterator last, F1 f1, F2 f2)
  525. {
  526. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F1)
  527. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F2)
  528. size_type count_elements = 0;
  529. for (; first != last; ++first, ++count_elements) {
  530. table_.emplace_and_visit(*first, f1, f2);
  531. }
  532. return count_elements;
  533. }
  534. template <class F1, class F2>
  535. size_type insert_and_visit(
  536. std::initializer_list<value_type> ilist, F1 f1, F2 f2)
  537. {
  538. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F1)
  539. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F2)
  540. return this->insert_and_visit(
  541. ilist.begin(), ilist.end(), std::ref(f1), std::ref(f2));
  542. }
  543. template <class F1, class F2>
  544. insert_return_type insert_and_visit(node_type&& nh, F1 f1, F2 f2)
  545. {
  546. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F1)
  547. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F2)
  548. using access = detail::foa::node_handle_access;
  549. if (nh.empty()) {
  550. return {false, node_type{}};
  551. }
  552. // Caveat: get_allocator() incurs synchronization (not cheap)
  553. BOOST_ASSERT(get_allocator() == nh.get_allocator());
  554. if (table_.insert_and_visit(std::move(access::element(nh)), f1, f2)) {
  555. access::reset(nh);
  556. return {true, node_type{}};
  557. } else {
  558. return {false, std::move(nh)};
  559. }
  560. }
  561. template <class Ty, class F1, class F2>
  562. BOOST_FORCEINLINE auto insert_and_cvisit(Ty&& value, F1 f1, F2 f2)
  563. -> decltype(table_.insert_and_cvisit(std::forward<Ty>(value), f1, f2))
  564. {
  565. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F1)
  566. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F2)
  567. return table_.insert_and_cvisit(std::forward<Ty>(value), f1, f2);
  568. }
  569. template <class F1, class F2>
  570. BOOST_FORCEINLINE bool insert_and_cvisit(init_type&& obj, F1 f1, F2 f2)
  571. {
  572. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F1)
  573. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F2)
  574. return table_.insert_and_cvisit(std::move(obj), f1, f2);
  575. }
  576. template <class InputIterator, class F1, class F2>
  577. size_type insert_and_cvisit(
  578. InputIterator first, InputIterator last, F1 f1, F2 f2)
  579. {
  580. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F1)
  581. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F2)
  582. size_type count_elements = 0;
  583. for (; first != last; ++first, ++count_elements) {
  584. table_.emplace_and_cvisit(*first, f1, f2);
  585. }
  586. return count_elements;
  587. }
  588. template <class F1, class F2>
  589. size_type insert_and_cvisit(
  590. std::initializer_list<value_type> ilist, F1 f1, F2 f2)
  591. {
  592. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F1)
  593. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F2)
  594. return this->insert_and_cvisit(
  595. ilist.begin(), ilist.end(), std::ref(f1), std::ref(f2));
  596. }
  597. template <class F1, class F2>
  598. insert_return_type insert_and_cvisit(node_type&& nh, F1 f1, F2 f2)
  599. {
  600. BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F1)
  601. BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F2)
  602. using access = detail::foa::node_handle_access;
  603. if (nh.empty()) {
  604. return {false, node_type{}};
  605. }
  606. // Caveat: get_allocator() incurs synchronization (not cheap)
  607. BOOST_ASSERT(get_allocator() == nh.get_allocator());
  608. if (table_.insert_and_cvisit(std::move(access::element(nh)), f1, f2)) {
  609. access::reset(nh);
  610. return {true, node_type{}};
  611. } else {
  612. return {false, std::move(nh)};
  613. }
  614. }
  615. template <class... Args> BOOST_FORCEINLINE bool emplace(Args&&... args)
  616. {
  617. return table_.emplace(std::forward<Args>(args)...);
  618. }
  619. template <class Arg, class... Args>
  620. BOOST_FORCEINLINE bool emplace_or_visit(Arg&& arg, Args&&... args)
  621. {
  622. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_INVOCABLE(Arg, Args...)
  623. return table_.emplace_or_visit(
  624. std::forward<Arg>(arg), std::forward<Args>(args)...);
  625. }
  626. template <class Arg, class... Args>
  627. BOOST_FORCEINLINE bool emplace_or_cvisit(Arg&& arg, Args&&... args)
  628. {
  629. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_CONST_INVOCABLE(Arg, Args...)
  630. return table_.emplace_or_cvisit(
  631. std::forward<Arg>(arg), std::forward<Args>(args)...);
  632. }
  633. template <class Arg1, class Arg2, class... Args>
  634. BOOST_FORCEINLINE bool emplace_and_visit(
  635. Arg1&& arg1, Arg2&& arg2, Args&&... args)
  636. {
  637. BOOST_UNORDERED_STATIC_ASSERT_PENULTIMATE_ARG_INVOCABLE(
  638. Arg1, Arg2, Args...)
  639. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_INVOCABLE(Arg2, Args...)
  640. return table_.emplace_and_visit(
  641. std::forward<Arg1>(arg1), std::forward<Arg2>(arg2),
  642. std::forward<Args>(args)...);
  643. }
  644. template <class Arg1, class Arg2, class... Args>
  645. BOOST_FORCEINLINE bool emplace_and_cvisit(
  646. Arg1&& arg1, Arg2&& arg2, Args&&... args)
  647. {
  648. BOOST_UNORDERED_STATIC_ASSERT_PENULTIMATE_ARG_INVOCABLE(
  649. Arg1, Arg2, Args...)
  650. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_CONST_INVOCABLE(Arg2, Args...)
  651. return table_.emplace_and_cvisit(
  652. std::forward<Arg1>(arg1), std::forward<Arg2>(arg2),
  653. std::forward<Args>(args)...);
  654. }
  655. template <class... Args>
  656. BOOST_FORCEINLINE bool try_emplace(key_type const& k, Args&&... args)
  657. {
  658. return table_.try_emplace(k, std::forward<Args>(args)...);
  659. }
  660. template <class... Args>
  661. BOOST_FORCEINLINE bool try_emplace(key_type&& k, Args&&... args)
  662. {
  663. return table_.try_emplace(std::move(k), std::forward<Args>(args)...);
  664. }
  665. template <class K, class... Args>
  666. BOOST_FORCEINLINE typename std::enable_if<
  667. detail::are_transparent<K, hasher, key_equal>::value, bool>::type
  668. try_emplace(K&& k, Args&&... args)
  669. {
  670. return table_.try_emplace(
  671. std::forward<K>(k), std::forward<Args>(args)...);
  672. }
  673. template <class Arg, class... Args>
  674. BOOST_FORCEINLINE bool try_emplace_or_visit(
  675. key_type const& k, Arg&& arg, Args&&... args)
  676. {
  677. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_INVOCABLE(Arg, Args...)
  678. return table_.try_emplace_or_visit(
  679. k, std::forward<Arg>(arg), std::forward<Args>(args)...);
  680. }
  681. template <class Arg, class... Args>
  682. BOOST_FORCEINLINE bool try_emplace_or_cvisit(
  683. key_type const& k, Arg&& arg, Args&&... args)
  684. {
  685. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_CONST_INVOCABLE(Arg, Args...)
  686. return table_.try_emplace_or_cvisit(
  687. k, std::forward<Arg>(arg), std::forward<Args>(args)...);
  688. }
  689. template <class Arg, class... Args>
  690. BOOST_FORCEINLINE bool try_emplace_or_visit(
  691. key_type&& k, Arg&& arg, Args&&... args)
  692. {
  693. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_INVOCABLE(Arg, Args...)
  694. return table_.try_emplace_or_visit(
  695. std::move(k), std::forward<Arg>(arg), std::forward<Args>(args)...);
  696. }
  697. template <class Arg, class... Args>
  698. BOOST_FORCEINLINE bool try_emplace_or_cvisit(
  699. key_type&& k, Arg&& arg, Args&&... args)
  700. {
  701. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_CONST_INVOCABLE(Arg, Args...)
  702. return table_.try_emplace_or_cvisit(
  703. std::move(k), std::forward<Arg>(arg), std::forward<Args>(args)...);
  704. }
  705. template <class K, class Arg, class... Args>
  706. BOOST_FORCEINLINE bool try_emplace_or_visit(
  707. K&& k, Arg&& arg, Args&&... args)
  708. {
  709. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_INVOCABLE(Arg, Args...)
  710. return table_.try_emplace_or_visit(std::forward<K>(k),
  711. std::forward<Arg>(arg), std::forward<Args>(args)...);
  712. }
  713. template <class K, class Arg, class... Args>
  714. BOOST_FORCEINLINE bool try_emplace_or_cvisit(
  715. K&& k, Arg&& arg, Args&&... args)
  716. {
  717. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_CONST_INVOCABLE(Arg, Args...)
  718. return table_.try_emplace_or_cvisit(std::forward<K>(k),
  719. std::forward<Arg>(arg), std::forward<Args>(args)...);
  720. }
  721. template <class Arg1, class Arg2, class... Args>
  722. BOOST_FORCEINLINE bool try_emplace_and_visit(
  723. key_type const& k, Arg1&& arg1, Arg2&& arg2, Args&&... args)
  724. {
  725. BOOST_UNORDERED_STATIC_ASSERT_PENULTIMATE_ARG_INVOCABLE(
  726. Arg1, Arg2, Args...)
  727. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_INVOCABLE(Arg2, Args...)
  728. return table_.try_emplace_and_visit(
  729. k, std::forward<Arg1>(arg1), std::forward<Arg2>(arg2),
  730. std::forward<Args>(args)...);
  731. }
  732. template <class Arg1, class Arg2, class... Args>
  733. BOOST_FORCEINLINE bool try_emplace_and_cvisit(
  734. key_type const& k, Arg1&& arg1, Arg2&& arg2, Args&&... args)
  735. {
  736. BOOST_UNORDERED_STATIC_ASSERT_PENULTIMATE_ARG_INVOCABLE(
  737. Arg1, Arg2, Args...)
  738. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_CONST_INVOCABLE(Arg2, Args...)
  739. return table_.try_emplace_and_cvisit(
  740. k, std::forward<Arg1>(arg1), std::forward<Arg2>(arg2),
  741. std::forward<Args>(args)...);
  742. }
  743. template <class Arg1, class Arg2, class... Args>
  744. BOOST_FORCEINLINE bool try_emplace_and_visit(
  745. key_type&& k, Arg1&& arg1, Arg2&& arg2, Args&&... args)
  746. {
  747. BOOST_UNORDERED_STATIC_ASSERT_PENULTIMATE_ARG_INVOCABLE(
  748. Arg1, Arg2, Args...)
  749. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_INVOCABLE(Arg2, Args...)
  750. return table_.try_emplace_and_visit(
  751. std::move(k), std::forward<Arg1>(arg1), std::forward<Arg2>(arg2),
  752. std::forward<Args>(args)...);
  753. }
  754. template <class Arg1, class Arg2, class... Args>
  755. BOOST_FORCEINLINE bool try_emplace_and_cvisit(
  756. key_type&& k, Arg1&& arg1, Arg2&& arg2, Args&&... args)
  757. {
  758. BOOST_UNORDERED_STATIC_ASSERT_PENULTIMATE_ARG_INVOCABLE(
  759. Arg1, Arg2, Args...)
  760. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_CONST_INVOCABLE(Arg2, Args...)
  761. return table_.try_emplace_and_cvisit(
  762. std::move(k), std::forward<Arg1>(arg1), std::forward<Arg2>(arg2),
  763. std::forward<Args>(args)...);
  764. }
  765. template <class K, class Arg1, class Arg2, class... Args>
  766. BOOST_FORCEINLINE bool try_emplace_and_visit(
  767. K&& k, Arg1&& arg1, Arg2&& arg2, Args&&... args)
  768. {
  769. BOOST_UNORDERED_STATIC_ASSERT_PENULTIMATE_ARG_INVOCABLE(
  770. Arg1, Arg2, Args...)
  771. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_INVOCABLE(Arg2, Args...)
  772. return table_.try_emplace_and_visit(std::forward<K>(k),
  773. std::forward<Arg1>(arg1), std::forward<Arg2>(arg2),
  774. std::forward<Args>(args)...);
  775. }
  776. template <class K, class Arg1, class Arg2, class... Args>
  777. BOOST_FORCEINLINE bool try_emplace_and_cvisit(
  778. K&& k, Arg1&& arg1, Arg2&& arg2, Args&&... args)
  779. {
  780. BOOST_UNORDERED_STATIC_ASSERT_PENULTIMATE_ARG_INVOCABLE(
  781. Arg1, Arg2, Args...)
  782. BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_CONST_INVOCABLE(Arg2, Args...)
  783. return table_.try_emplace_and_cvisit(std::forward<K>(k),
  784. std::forward<Arg1>(arg1), std::forward<Arg2>(arg2),
  785. std::forward<Args>(args)...);
  786. }
  787. BOOST_FORCEINLINE size_type erase(key_type const& k)
  788. {
  789. return table_.erase(k);
  790. }
  791. template <class K>
  792. BOOST_FORCEINLINE typename std::enable_if<
  793. detail::are_transparent<K, hasher, key_equal>::value, size_type>::type
  794. erase(K&& k)
  795. {
  796. return table_.erase(std::forward<K>(k));
  797. }
  798. template <class F>
  799. BOOST_FORCEINLINE size_type erase_if(key_type const& k, F f)
  800. {
  801. return table_.erase_if(k, f);
  802. }
  803. template <class K, class F>
  804. BOOST_FORCEINLINE typename std::enable_if<
  805. detail::are_transparent<K, hasher, key_equal>::value &&
  806. !detail::is_execution_policy<K>::value,
  807. size_type>::type
  808. erase_if(K&& k, F f)
  809. {
  810. return table_.erase_if(std::forward<K>(k), f);
  811. }
  812. #if defined(BOOST_UNORDERED_PARALLEL_ALGORITHMS)
  813. template <class ExecPolicy, class F>
  814. typename std::enable_if<detail::is_execution_policy<ExecPolicy>::value,
  815. void>::type
  816. erase_if(ExecPolicy&& p, F f)
  817. {
  818. BOOST_UNORDERED_STATIC_ASSERT_EXEC_POLICY(ExecPolicy)
  819. table_.erase_if(p, f);
  820. }
  821. #endif
  822. template <class F> size_type erase_if(F f) { return table_.erase_if(f); }
  823. void swap(concurrent_node_map& other) noexcept(
  824. boost::allocator_is_always_equal<Allocator>::type::value ||
  825. boost::allocator_propagate_on_container_swap<Allocator>::type::value)
  826. {
  827. return table_.swap(other.table_);
  828. }
  829. node_type extract(key_type const& key)
  830. {
  831. node_type nh;
  832. table_.extract(key, detail::foa::node_handle_emplacer(nh));
  833. return nh;
  834. }
  835. template <class K>
  836. typename std::enable_if<
  837. detail::are_transparent<K, hasher, key_equal>::value, node_type>::type
  838. extract(K const& key)
  839. {
  840. node_type nh;
  841. table_.extract(key, detail::foa::node_handle_emplacer(nh));
  842. return nh;
  843. }
  844. template <class F>
  845. node_type extract_if(key_type const& key, F f)
  846. {
  847. node_type nh;
  848. table_.extract_if(key, f, detail::foa::node_handle_emplacer(nh));
  849. return nh;
  850. }
  851. template <class K, class F>
  852. typename std::enable_if<
  853. detail::are_transparent<K, hasher, key_equal>::value, node_type>::type
  854. extract_if(K const& key, F f)
  855. {
  856. node_type nh;
  857. table_.extract_if(key, f, detail::foa::node_handle_emplacer(nh));
  858. return nh;
  859. }
  860. void clear() noexcept { table_.clear(); }
  861. template <typename H2, typename P2>
  862. size_type merge(concurrent_node_map<Key, T, H2, P2, Allocator>& x)
  863. {
  864. BOOST_ASSERT(get_allocator() == x.get_allocator());
  865. return table_.merge(x.table_);
  866. }
  867. template <typename H2, typename P2>
  868. size_type merge(concurrent_node_map<Key, T, H2, P2, Allocator>&& x)
  869. {
  870. return merge(x);
  871. }
  872. BOOST_FORCEINLINE size_type count(key_type const& k) const
  873. {
  874. return table_.count(k);
  875. }
  876. template <class K>
  877. BOOST_FORCEINLINE typename std::enable_if<
  878. detail::are_transparent<K, hasher, key_equal>::value, size_type>::type
  879. count(K const& k)
  880. {
  881. return table_.count(k);
  882. }
  883. BOOST_FORCEINLINE bool contains(key_type const& k) const
  884. {
  885. return table_.contains(k);
  886. }
  887. template <class K>
  888. BOOST_FORCEINLINE typename std::enable_if<
  889. detail::are_transparent<K, hasher, key_equal>::value, bool>::type
  890. contains(K const& k) const
  891. {
  892. return table_.contains(k);
  893. }
  894. /// Hash Policy
  895. ///
  896. size_type bucket_count() const noexcept { return table_.capacity(); }
  897. float load_factor() const noexcept { return table_.load_factor(); }
  898. float max_load_factor() const noexcept
  899. {
  900. return table_.max_load_factor();
  901. }
  902. void max_load_factor(float) {}
  903. size_type max_load() const noexcept { return table_.max_load(); }
  904. void rehash(size_type n) { table_.rehash(n); }
  905. void reserve(size_type n) { table_.reserve(n); }
  906. #if defined(BOOST_UNORDERED_ENABLE_STATS)
  907. /// Stats
  908. ///
  909. stats get_stats() const { return table_.get_stats(); }
  910. void reset_stats() noexcept { table_.reset_stats(); }
  911. #endif
  912. /// Observers
  913. ///
  914. allocator_type get_allocator() const noexcept
  915. {
  916. return table_.get_allocator();
  917. }
  918. hasher hash_function() const { return table_.hash_function(); }
  919. key_equal key_eq() const { return table_.key_eq(); }
  920. };
  921. template <class Key, class T, class Hash, class KeyEqual, class Allocator>
  922. bool operator==(
  923. concurrent_node_map<Key, T, Hash, KeyEqual, Allocator> const& lhs,
  924. concurrent_node_map<Key, T, Hash, KeyEqual, Allocator> const& rhs)
  925. {
  926. return lhs.table_ == rhs.table_;
  927. }
  928. template <class Key, class T, class Hash, class KeyEqual, class Allocator>
  929. bool operator!=(
  930. concurrent_node_map<Key, T, Hash, KeyEqual, Allocator> const& lhs,
  931. concurrent_node_map<Key, T, Hash, KeyEqual, Allocator> const& rhs)
  932. {
  933. return !(lhs == rhs);
  934. }
  935. template <class Key, class T, class Hash, class Pred, class Alloc>
  936. void swap(concurrent_node_map<Key, T, Hash, Pred, Alloc>& x,
  937. concurrent_node_map<Key, T, Hash, Pred, Alloc>& y)
  938. noexcept(noexcept(x.swap(y)))
  939. {
  940. x.swap(y);
  941. }
  942. template <class K, class T, class H, class P, class A, class Predicate>
  943. typename concurrent_node_map<K, T, H, P, A>::size_type erase_if(
  944. concurrent_node_map<K, T, H, P, A>& c, Predicate pred)
  945. {
  946. return c.table_.erase_if(pred);
  947. }
  948. template<class Archive, class K, class V, class H, class KE, class A>
  949. void serialize(
  950. Archive& ar, concurrent_node_map<K, V, H, KE, A>& c, unsigned int)
  951. {
  952. ar & core::make_nvp("table",c.table_);
  953. }
  954. #if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
  955. template <class InputIterator,
  956. class Hash =
  957. boost::hash<boost::unordered::detail::iter_key_t<InputIterator> >,
  958. class Pred =
  959. std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
  960. class Allocator = std::allocator<
  961. boost::unordered::detail::iter_to_alloc_t<InputIterator> >,
  962. class = std::enable_if_t<detail::is_input_iterator_v<InputIterator> >,
  963. class = std::enable_if_t<detail::is_hash_v<Hash> >,
  964. class = std::enable_if_t<detail::is_pred_v<Pred> >,
  965. class = std::enable_if_t<detail::is_allocator_v<Allocator> > >
  966. concurrent_node_map(InputIterator, InputIterator,
  967. std::size_t = boost::unordered::detail::foa::default_bucket_count,
  968. Hash = Hash(), Pred = Pred(), Allocator = Allocator())
  969. -> concurrent_node_map<
  970. boost::unordered::detail::iter_key_t<InputIterator>,
  971. boost::unordered::detail::iter_val_t<InputIterator>, Hash, Pred,
  972. Allocator>;
  973. template <class Key, class T,
  974. class Hash = boost::hash<std::remove_const_t<Key> >,
  975. class Pred = std::equal_to<std::remove_const_t<Key> >,
  976. class Allocator = std::allocator<std::pair<const Key, T> >,
  977. class = std::enable_if_t<detail::is_hash_v<Hash> >,
  978. class = std::enable_if_t<detail::is_pred_v<Pred> >,
  979. class = std::enable_if_t<detail::is_allocator_v<Allocator> > >
  980. concurrent_node_map(std::initializer_list<std::pair<Key, T> >,
  981. std::size_t = boost::unordered::detail::foa::default_bucket_count,
  982. Hash = Hash(), Pred = Pred(), Allocator = Allocator())
  983. -> concurrent_node_map<std::remove_const_t<Key>, T, Hash, Pred,
  984. Allocator>;
  985. template <class InputIterator, class Allocator,
  986. class = std::enable_if_t<detail::is_input_iterator_v<InputIterator> >,
  987. class = std::enable_if_t<detail::is_allocator_v<Allocator> > >
  988. concurrent_node_map(InputIterator, InputIterator, std::size_t, Allocator)
  989. -> concurrent_node_map<
  990. boost::unordered::detail::iter_key_t<InputIterator>,
  991. boost::unordered::detail::iter_val_t<InputIterator>,
  992. boost::hash<boost::unordered::detail::iter_key_t<InputIterator> >,
  993. std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
  994. Allocator>;
  995. template <class InputIterator, class Allocator,
  996. class = std::enable_if_t<detail::is_input_iterator_v<InputIterator> >,
  997. class = std::enable_if_t<detail::is_allocator_v<Allocator> > >
  998. concurrent_node_map(InputIterator, InputIterator, Allocator)
  999. -> concurrent_node_map<
  1000. boost::unordered::detail::iter_key_t<InputIterator>,
  1001. boost::unordered::detail::iter_val_t<InputIterator>,
  1002. boost::hash<boost::unordered::detail::iter_key_t<InputIterator> >,
  1003. std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
  1004. Allocator>;
  1005. template <class InputIterator, class Hash, class Allocator,
  1006. class = std::enable_if_t<detail::is_hash_v<Hash> >,
  1007. class = std::enable_if_t<detail::is_input_iterator_v<InputIterator> >,
  1008. class = std::enable_if_t<detail::is_allocator_v<Allocator> > >
  1009. concurrent_node_map(
  1010. InputIterator, InputIterator, std::size_t, Hash, Allocator)
  1011. -> concurrent_node_map<
  1012. boost::unordered::detail::iter_key_t<InputIterator>,
  1013. boost::unordered::detail::iter_val_t<InputIterator>, Hash,
  1014. std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
  1015. Allocator>;
  1016. template <class Key, class T, class Allocator,
  1017. class = std::enable_if_t<detail::is_allocator_v<Allocator> > >
  1018. concurrent_node_map(std::initializer_list<std::pair<Key, T> >, std::size_t,
  1019. Allocator) -> concurrent_node_map<std::remove_const_t<Key>, T,
  1020. boost::hash<std::remove_const_t<Key> >,
  1021. std::equal_to<std::remove_const_t<Key> >, Allocator>;
  1022. template <class Key, class T, class Allocator,
  1023. class = std::enable_if_t<detail::is_allocator_v<Allocator> > >
  1024. concurrent_node_map(std::initializer_list<std::pair<Key, T> >, Allocator)
  1025. -> concurrent_node_map<std::remove_const_t<Key>, T,
  1026. boost::hash<std::remove_const_t<Key> >,
  1027. std::equal_to<std::remove_const_t<Key> >, Allocator>;
  1028. template <class Key, class T, class Hash, class Allocator,
  1029. class = std::enable_if_t<detail::is_hash_v<Hash> >,
  1030. class = std::enable_if_t<detail::is_allocator_v<Allocator> > >
  1031. concurrent_node_map(std::initializer_list<std::pair<Key, T> >, std::size_t,
  1032. Hash, Allocator) -> concurrent_node_map<std::remove_const_t<Key>, T,
  1033. Hash, std::equal_to<std::remove_const_t<Key> >, Allocator>;
  1034. #endif
  1035. } // namespace unordered
  1036. } // namespace boost
  1037. #endif // BOOST_UNORDERED_CONCURRENT_NODE_MAP_HPP