options.hpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2013-2013
  4. //
  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 http://www.boost.org/libs/container for documentation.
  10. //
  11. /////////////////////////////////////////////////////////////////////////////
  12. #ifndef BOOST_CONTAINER_OPTIONS_HPP
  13. #define BOOST_CONTAINER_OPTIONS_HPP
  14. #ifndef BOOST_CONFIG_HPP
  15. # include <boost/config.hpp>
  16. #endif
  17. #if defined(BOOST_HAS_PRAGMA_ONCE)
  18. # pragma once
  19. #endif
  20. #include <boost/container/detail/config_begin.hpp>
  21. #include <boost/container/container_fwd.hpp>
  22. #include <boost/container/detail/workaround.hpp>
  23. #include <boost/intrusive/pack_options.hpp>
  24. namespace boost {
  25. namespace container {
  26. ////////////////////////////////////////////////////////////////
  27. //
  28. //
  29. // OPTIONS FOR ASSOCIATIVE TREE-BASED CONTAINERS
  30. //
  31. //
  32. ////////////////////////////////////////////////////////////////
  33. //! Enumeration used to configure ordered associative containers
  34. //! with a concrete tree implementation.
  35. enum tree_type_enum
  36. {
  37. red_black_tree,
  38. avl_tree,
  39. scapegoat_tree,
  40. splay_tree
  41. };
  42. #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  43. template<tree_type_enum TreeType, bool OptimizeSize>
  44. struct tree_opt
  45. {
  46. static const boost::container::tree_type_enum tree_type = TreeType;
  47. static const bool optimize_size = OptimizeSize;
  48. };
  49. typedef tree_opt<red_black_tree, true> tree_assoc_defaults;
  50. #endif //!defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  51. //!This option setter specifies the underlying tree type
  52. //!(red-black, AVL, Scapegoat or Splay) for ordered associative containers
  53. BOOST_INTRUSIVE_OPTION_CONSTANT(tree_type, tree_type_enum, TreeType, tree_type)
  54. //!This option setter specifies if node size is optimized
  55. //!storing rebalancing data masked into pointers for ordered associative containers
  56. BOOST_INTRUSIVE_OPTION_CONSTANT(optimize_size, bool, Enabled, optimize_size)
  57. //! Helper metafunction to combine options into a single type to be used
  58. //! by \c boost::container::set, \c boost::container::multiset
  59. //! \c boost::container::map and \c boost::container::multimap.
  60. //! Supported options are: \c boost::container::optimize_size and \c boost::container::tree_type
  61. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) || defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
  62. template<class ...Options>
  63. #else
  64. template<class O1 = void, class O2 = void, class O3 = void, class O4 = void>
  65. #endif
  66. struct tree_assoc_options
  67. {
  68. /// @cond
  69. typedef typename ::boost::intrusive::pack_options
  70. < tree_assoc_defaults,
  71. #if !defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
  72. O1, O2, O3, O4
  73. #else
  74. Options...
  75. #endif
  76. >::type packed_options;
  77. typedef tree_opt<packed_options::tree_type, packed_options::optimize_size> implementation_defined;
  78. /// @endcond
  79. typedef implementation_defined type;
  80. };
  81. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  82. //! Helper alias metafunction to combine options into a single type to be used
  83. //! by tree-based associative containers
  84. template<class ...Options>
  85. using tree_assoc_options_t = typename boost::container::tree_assoc_options<Options...>::type;
  86. #endif
  87. ////////////////////////////////////////////////////////////////
  88. //
  89. //
  90. // OPTIONS FOR ASSOCIATIVE HASH-BASED CONTAINERS
  91. //
  92. //
  93. ////////////////////////////////////////////////////////////////
  94. #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  95. template<bool StoreHash, bool CacheBegin, bool LinearBuckets, bool FastmodBuckets>
  96. struct hash_opt
  97. {
  98. static const bool store_hash = StoreHash;
  99. static const bool cache_begin = CacheBegin;
  100. static const bool linear_buckets = LinearBuckets;
  101. static const bool fastmod_buckets = FastmodBuckets;
  102. };
  103. typedef hash_opt<false, false, false, false> hash_assoc_defaults;
  104. #endif //!defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  105. //!This option setter specifies if nodes also store the hash value
  106. //!so that search and rehashing for hash-expensive types is improved.
  107. //!This option might degrade performance for easy to hash types (like integers)
  108. BOOST_INTRUSIVE_OPTION_CONSTANT(store_hash, bool, Enabled, store_hash)
  109. //!This option setter specifies if the container will cache the first
  110. //!non-empty bucket so that begin() is O(1) instead of searching for the
  111. //!first non-empty bucket (which can be O(bucket_size()))
  112. BOOST_INTRUSIVE_OPTION_CONSTANT(cache_begin, bool, Enabled, cache_begin)
  113. BOOST_INTRUSIVE_OPTION_CONSTANT(linear_buckets, bool, Enabled, linear_buckets)
  114. BOOST_INTRUSIVE_OPTION_CONSTANT(fastmod_buckets, bool, Enabled, fastmod_buckets)
  115. //! Helper metafunction to combine options into a single type to be used
  116. //! by \c boost::container::hash_set, \c boost::container::hash_multiset
  117. //! \c boost::container::hash_map and \c boost::container::hash_multimap.
  118. //! Supported options are: \c boost::container::store_hash
  119. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) || defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
  120. template<class ...Options>
  121. #else
  122. template<class O1 = void, class O2 = void, class O3 = void, class O4 = void>
  123. #endif
  124. struct hash_assoc_options
  125. {
  126. /// @cond
  127. typedef typename ::boost::intrusive::pack_options
  128. < hash_assoc_defaults,
  129. #if !defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
  130. O1, O2, O3, O4
  131. #else
  132. Options...
  133. #endif
  134. >::type packed_options;
  135. typedef hash_opt<packed_options::store_hash
  136. ,packed_options::cache_begin
  137. ,packed_options::linear_buckets
  138. ,packed_options::fastmod_buckets
  139. > implementation_defined;
  140. /// @endcond
  141. typedef implementation_defined type;
  142. };
  143. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  144. //! Helper alias metafunction to combine options into a single type to be used
  145. //! by hash-based associative containers
  146. template<class ...Options>
  147. using hash_assoc_options_t = typename boost::container::hash_assoc_options<Options...>::type;
  148. #endif
  149. ////////////////////////////////////////////////////////////////
  150. //
  151. //
  152. // OPTIONS FOR VECTOR-BASED CONTAINERS
  153. //
  154. //
  155. ////////////////////////////////////////////////////////////////
  156. #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  157. template<class T, class Default>
  158. struct default_if_void
  159. {
  160. typedef T type;
  161. };
  162. template<class Default>
  163. struct default_if_void<void, Default>
  164. {
  165. typedef Default type;
  166. };
  167. template<std::size_t N, std::size_t DefaultN>
  168. struct default_if_zero
  169. {
  170. static const std::size_t value = N;
  171. };
  172. template<std::size_t DefaultN>
  173. struct default_if_zero<0u, DefaultN>
  174. {
  175. static const std::size_t value = DefaultN;
  176. };
  177. #endif
  178. #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  179. template<class AllocTraits, class StoredSizeType>
  180. struct get_stored_size_type_with_alloctraits
  181. {
  182. typedef StoredSizeType type;
  183. };
  184. template<class AllocTraits>
  185. struct get_stored_size_type_with_alloctraits<AllocTraits, void>
  186. {
  187. typedef typename AllocTraits::size_type type;
  188. };
  189. template<class GrowthType, class StoredSizeType>
  190. struct vector_opt
  191. {
  192. typedef GrowthType growth_factor_type;
  193. typedef StoredSizeType stored_size_type;
  194. template<class AllocTraits>
  195. struct get_stored_size_type
  196. : get_stored_size_type_with_alloctraits<AllocTraits, StoredSizeType>
  197. {};
  198. };
  199. class default_next_capacity;
  200. typedef vector_opt<void, void> vector_null_opt;
  201. #else //!defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  202. //!This growth factor argument specifies that the container should increase its
  203. //!capacity a 50% when existing capacity is exhausted.
  204. struct growth_factor_50{};
  205. //!This growth factor argument specifies that the container should increase its
  206. //!capacity a 60% when existing capacity is exhausted.
  207. struct growth_factor_60{};
  208. //!This growth factor argument specifies that the container should increase its
  209. //!capacity a 100% (doubling its capacity) when existing capacity is exhausted.
  210. struct growth_factor_100{};
  211. #endif //!defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  212. //!This option setter specifies the growth factor strategy of the underlying vector.
  213. //!
  214. //!\tparam GrowthFactor A function object that has the following signature:<br/><br/>
  215. //!`template<class SizeType>`<br/>
  216. //!`SizeType operator()(SizeType cur_cap, SizeType add_min_cap, SizeType max_cap) const;`.<br/><br/>
  217. //!`cur_cap` is the current capacity, `add_min_cap` is the minimum additional capacity
  218. //!we want to achieve and `max_cap` is the maximum capacity that the allocator or other
  219. //!factors allow. The implementation should return a value between `cur_cap` + `add_min_cap`
  220. //!and `max_cap`. `cur_cap` + `add_min_cap` is guaranteed not to overflow/wraparound,
  221. //! but the implementation should handle wraparound produced by the growth factor.
  222. //!
  223. //!Predefined growth factors that can be passed as arguments to this option are:
  224. //!\c boost::container::growth_factor_50
  225. //!\c boost::container::growth_factor_60
  226. //!\c boost::container::growth_factor_100
  227. //!
  228. //!If this option is not specified, a default will be used by the container.
  229. BOOST_INTRUSIVE_OPTION_TYPE(growth_factor, GrowthFactor, GrowthFactor, growth_factor_type)
  230. //!This option specifies the unsigned integer type that a user wants the container
  231. //!to use to hold size-related information inside a container (e.g. current size, current capacity).
  232. //!
  233. //!\tparam StoredSizeType An unsigned integer type. It shall be smaller than than the size
  234. //! of the size_type deduced from `allocator_traits<A>::size_type` or the same type.
  235. //!
  236. //!If the maximum capacity() to be used is limited, a user can try to use 8-bit, 16-bit
  237. //!(e.g. in 32-bit machines), or 32-bit size types (e.g. in a 64 bit machine) to see if some
  238. //!memory can be saved for empty vectors. This could potentially performance benefits due to better
  239. //!cache usage.
  240. //!
  241. //!Note that alignment requirements can disallow theoretical space savings. Example:
  242. //!\c vector holds a pointer and two size types (for size and capacity), in a 32 bit machine
  243. //!a 8 bit size type (total size: 4 byte pointer + 2 x 1 byte sizes = 6 bytes)
  244. //!will not save space when comparing two 16-bit size types because usually
  245. //!a 32 bit alignment is required for vector and the size will be rounded to 8 bytes. In a 64-bit
  246. //!machine a 16 bit size type does not usually save memory when comparing to a 32-bit size type.
  247. //!Measure the size of the resulting container and do not assume a smaller \c stored_size
  248. //!will always lead to a smaller sizeof(container).
  249. //!
  250. //!If a user tries to insert more elements than representable by \c stored_size, vector
  251. //!will throw a length_error.
  252. //!
  253. //!If this option is not specified, `allocator_traits<A>::size_type` (usually std::size_t) will
  254. //!be used to store size-related information inside the container.
  255. BOOST_INTRUSIVE_OPTION_TYPE(stored_size, StoredSizeType, StoredSizeType, stored_size_type)
  256. //! Helper metafunction to combine options into a single type to be used
  257. //! by \c boost::container::vector.
  258. //! Supported options are: \c boost::container::growth_factor and \c boost::container::stored_size
  259. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) || defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
  260. template<class ...Options>
  261. #else
  262. template<class O1 = void, class O2 = void, class O3 = void, class O4 = void>
  263. #endif
  264. struct vector_options
  265. {
  266. /// @cond
  267. typedef typename ::boost::intrusive::pack_options
  268. < vector_null_opt,
  269. #if !defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
  270. O1, O2, O3, O4
  271. #else
  272. Options...
  273. #endif
  274. >::type packed_options;
  275. typedef vector_opt< typename packed_options::growth_factor_type
  276. , typename packed_options::stored_size_type> implementation_defined;
  277. /// @endcond
  278. typedef implementation_defined type;
  279. };
  280. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  281. //! Helper alias metafunction to combine options into a single type to be used
  282. //! by \c boost::container::vector.
  283. //! Supported options are: \c boost::container::growth_factor and \c boost::container::stored_size
  284. template<class ...Options>
  285. using vector_options_t = typename boost::container::vector_options<Options...>::type;
  286. #endif
  287. ////////////////////////////////////////////////////////////////
  288. //
  289. //
  290. // OPTIONS FOR SMALL-VECTOR CONTAINER
  291. //
  292. //
  293. ////////////////////////////////////////////////////////////////
  294. //! This option specifies the desired alignment for the value_type stored
  295. //! in the container.
  296. //! A value zero represents the natural alignment.
  297. //!
  298. //!\tparam Alignment An unsigned integer value. Must be power of two.
  299. BOOST_INTRUSIVE_OPTION_CONSTANT(inplace_alignment, std::size_t, Alignment, inplace_alignment)
  300. #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  301. template<class GrowthType, std::size_t InplaceAlignment>
  302. struct small_vector_opt
  303. {
  304. typedef GrowthType growth_factor_type;
  305. static const std::size_t inplace_alignment = InplaceAlignment;
  306. };
  307. typedef small_vector_opt<void, 0u> small_vector_null_opt;
  308. #endif //!defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  309. //! Helper metafunction to combine options into a single type to be used
  310. //! by \c boost::container::small_vector.
  311. //! Supported options are: \c boost::container::growth_factor and \c boost::container::inplace_alignment
  312. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) || defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
  313. template<class ...Options>
  314. #else
  315. template<class O1 = void, class O2 = void, class O3 = void, class O4 = void>
  316. #endif
  317. struct small_vector_options
  318. {
  319. /// @cond
  320. typedef typename ::boost::intrusive::pack_options
  321. < small_vector_null_opt,
  322. #if !defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
  323. O1, O2, O3, O4
  324. #else
  325. Options...
  326. #endif
  327. >::type packed_options;
  328. typedef small_vector_opt< typename packed_options::growth_factor_type
  329. , packed_options::inplace_alignment> implementation_defined;
  330. /// @endcond
  331. typedef implementation_defined type;
  332. };
  333. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  334. //! Helper alias metafunction to combine options into a single type to be used
  335. //! by \c boost::container::small_vector.
  336. //! Supported options are: \c boost::container::growth_factor and \c boost::container::stored_size
  337. template<class ...Options>
  338. using small_vector_options_t = typename boost::container::small_vector_options<Options...>::type;
  339. #endif
  340. ////////////////////////////////////////////////////////////////
  341. //
  342. //
  343. // OPTIONS FOR STATIC-VECTOR CONTAINER
  344. //
  345. //
  346. ////////////////////////////////////////////////////////////////
  347. //!This option specifies if the container will throw if in
  348. //!the static capacity is not sufficient to hold the required
  349. //!values. If false is specified, insufficient capacity will
  350. //!lead to BOOST_ASSERT, and if this assertion returns, to undefined behaviour,
  351. //!which potentially can lead to better static_vector performance.
  352. //!The default value is true.
  353. //!
  354. //!\tparam ThrowOnExhaustion A boolean value. True if throw is required.
  355. BOOST_INTRUSIVE_OPTION_CONSTANT(throw_on_overflow, bool, ThrowOnOverflow, throw_on_overflow)
  356. #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  357. template<bool ThrowOnOverflow, std::size_t InplaceAlignment>
  358. struct static_vector_opt
  359. {
  360. static const bool throw_on_overflow = ThrowOnOverflow;
  361. static const std::size_t inplace_alignment = InplaceAlignment;
  362. };
  363. typedef static_vector_opt<true, 0u> static_vector_null_opt;
  364. #endif //!defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  365. //! Helper metafunction to combine options into a single type to be used
  366. //! by \c boost::container::static_vector.
  367. //! Supported options are: \c boost::container::throw_on_overflow and \c boost::container::inplace_alignment
  368. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) || defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
  369. template<class ...Options>
  370. #else
  371. template<class O1 = void, class O2 = void, class O3 = void, class O4 = void>
  372. #endif
  373. struct static_vector_options
  374. {
  375. /// @cond
  376. typedef typename ::boost::intrusive::pack_options
  377. < static_vector_null_opt,
  378. #if !defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
  379. O1, O2, O3, O4
  380. #else
  381. Options...
  382. #endif
  383. >::type packed_options;
  384. typedef static_vector_opt< packed_options::throw_on_overflow
  385. , packed_options::inplace_alignment> implementation_defined;
  386. /// @endcond
  387. typedef implementation_defined type;
  388. };
  389. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  390. //! Helper alias metafunction to combine options into a single type to be used
  391. //! by \c boost::container::static_vector.
  392. //! Supported options are: \c boost::container::growth_factor and \c boost::container::stored_size
  393. template<class ...Options>
  394. using static_vector_options_t = typename boost::container::static_vector_options<Options...>::type;
  395. #endif
  396. ////////////////////////////////////////////////////////////////
  397. //
  398. //
  399. // OPTIONS FOR DEVECTOR CONTAINER
  400. //
  401. //
  402. ////////////////////////////////////////////////////////////////
  403. //!Thse options specify the relocation strategy of devector.
  404. //!
  405. //!Predefined relocation limits that can be passed as arguments to this option are:
  406. //!\c boost::container::relocate_on_66
  407. //!\c boost::container::relocate_on_75
  408. //!\c boost::container::relocate_on_80
  409. //!\c boost::container::relocate_on_85
  410. //!\c boost::container::relocate_on_90
  411. //!
  412. //!If this option is not specified, a default will be used by the container.
  413. //!
  414. //!Note: Repeated insertions at only one end (only back insertions or only front insertions) usually will
  415. //!lead to a single relocation when `relocate_on_66` is used and two relocations when `relocate_on_90`
  416. //!is used.
  417. #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  418. BOOST_INTRUSIVE_OPTION_CONSTANT(relocate_on, std::size_t, Fraction, free_fraction)
  419. struct relocate_on_66 : public relocate_on<3U>{};
  420. struct relocate_on_75 : public relocate_on<4U> {};
  421. struct relocate_on_80 : public relocate_on<5U> {};
  422. struct relocate_on_85 : public relocate_on<7U> {};
  423. struct relocate_on_90 : public relocate_on<10U> {};
  424. template<class GrowthType, class StoredSizeType, std::size_t FreeFraction>
  425. struct devector_opt
  426. : vector_opt<GrowthType, StoredSizeType>
  427. {
  428. static const std::size_t free_fraction = FreeFraction;
  429. };
  430. typedef devector_opt<void, void, 0u> devector_null_opt;
  431. #else
  432. //!This relocation condition option specifies that the container will never relocate
  433. //!elements when there is no space at the side the insertion should
  434. //!take place
  435. struct relocate_never;
  436. //!This relocation condition option specifies that the container will relocate
  437. //!all elements when there is no space at the side the insertion should
  438. //!take place and memory usage is below 66% (2/3)
  439. struct relocate_on_66;
  440. //!This relocation condition option specifies that the container will relocate
  441. //!all elements when there is no space at the side the insertion should
  442. //!take place and memory usage is below 75% (3/4)
  443. struct relocate_on_75;
  444. //!This relocation condition option specifies that the container will relocate
  445. //!all elements when there is no space at the side the insertion should
  446. //!take place and memory usage is below 80% (4/5)
  447. struct relocate_on_80;
  448. //!This relocation condition option specifies that the container will relocate
  449. //!all elements when there is no space at the side the insertion should
  450. //!take place and memory usage is below 85% (6/7)
  451. struct relocate_on_85;
  452. //!This relocation condition option specifies that the container will relocate
  453. //!all elements when there is no space at the side the insertion should
  454. //!take place and memory usage is below 90% (9/10)
  455. struct relocate_on_90;
  456. #endif
  457. //! Helper metafunction to combine options into a single type to be used
  458. //! by \c boost::container::devector.
  459. //! Supported options are: \c boost::container::growth_factor, \c boost::container::stored_size
  460. //! and \c boost::container::relocate_on
  461. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) || defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
  462. template<class ...Options>
  463. #else
  464. template<class O1 = void, class O2 = void, class O3 = void, class O4 = void>
  465. #endif
  466. struct devector_options
  467. {
  468. /// @cond
  469. typedef typename ::boost::intrusive::pack_options
  470. < devector_null_opt,
  471. #if !defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
  472. O1, O2, O3, O4
  473. #else
  474. Options...
  475. #endif
  476. >::type packed_options;
  477. typedef devector_opt< typename packed_options::growth_factor_type
  478. , typename packed_options::stored_size_type
  479. , packed_options::free_fraction
  480. > implementation_defined;
  481. /// @endcond
  482. typedef implementation_defined type;
  483. };
  484. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  485. //! Helper alias metafunction to combine options into a single type to be used
  486. //! by \c boost::container::devector.
  487. //! Supported options are: \c boost::container::growth_factor and \c boost::container::stored_size
  488. template<class ...Options>
  489. using devector_options_t = typename boost::container::devector_options<Options...>::type;
  490. #endif
  491. ////////////////////////////////////////////////////////////////
  492. //
  493. //
  494. // OPTIONS FOR DEQUE-BASED CONTAINERS
  495. //
  496. //
  497. ////////////////////////////////////////////////////////////////
  498. #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  499. template<std::size_t BlockBytes, std::size_t BlockSize>
  500. struct deque_opt
  501. {
  502. static const std::size_t block_bytes = BlockBytes;
  503. static const std::size_t block_size = BlockSize;
  504. BOOST_CONTAINER_STATIC_ASSERT_MSG(!(block_bytes && block_size), "block_bytes and block_size can't be specified at the same time");
  505. };
  506. typedef deque_opt<0u, 0u> deque_null_opt;
  507. #endif
  508. //! Helper metafunction to combine options into a single type to be used
  509. //! by \c boost::container::deque.
  510. //! Supported options are: \c boost::container::block_bytes
  511. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) || defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
  512. template<class ...Options>
  513. #else
  514. template<class O1 = void, class O2 = void, class O3 = void, class O4 = void>
  515. #endif
  516. struct deque_options
  517. {
  518. /// @cond
  519. typedef typename ::boost::intrusive::pack_options
  520. < deque_null_opt,
  521. #if !defined(BOOST_CONTAINER_VARIADIC_TEMPLATES)
  522. O1, O2, O3, O4
  523. #else
  524. Options...
  525. #endif
  526. >::type packed_options;
  527. typedef deque_opt< packed_options::block_bytes, packed_options::block_size > implementation_defined;
  528. /// @endcond
  529. typedef implementation_defined type;
  530. };
  531. #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  532. //! Helper alias metafunction to combine options into a single type to be used
  533. //! by \c boost::container::deque.
  534. //! Supported options are: \c boost::container::block_bytes
  535. template<class ...Options>
  536. using deque_options_t = typename boost::container::deque_options<Options...>::type;
  537. #endif
  538. //!This option specifies the maximum size of a block in bytes: this delimites the number of contiguous elements
  539. //!that will be allocated by deque as min(1u, BlockBytes/sizeof(value_type))
  540. //!A value zero represents the default value.
  541. //!
  542. //!\tparam BlockBytes An unsigned integer value.
  543. BOOST_INTRUSIVE_OPTION_CONSTANT(block_bytes, std::size_t, BlockBytes, block_bytes)
  544. //!This option specifies the size of a block, delimites the number of contiguous elements
  545. //!that will be allocated by deque as BlockSize.
  546. //!A value zero represents the default value.
  547. //!
  548. //!\tparam BlockBytes An unsigned integer value.
  549. BOOST_INTRUSIVE_OPTION_CONSTANT(block_size, std::size_t, BlockSize, block_size)
  550. } //namespace container {
  551. } //namespace boost {
  552. #include <boost/container/detail/config_end.hpp>
  553. #endif //#ifndef BOOST_CONTAINER_OPTIONS_HPP