static_vector.hpp 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290
  1. // Boost.Container static_vector
  2. //
  3. // Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland.
  4. // Copyright (c) 2011-2013 Andrew Hundt.
  5. // Copyright (c) 2013-2014 Ion Gaztanaga
  6. //
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_CONTAINER_STATIC_VECTOR_HPP
  11. #define BOOST_CONTAINER_STATIC_VECTOR_HPP
  12. #ifndef BOOST_CONFIG_HPP
  13. # include <boost/config.hpp>
  14. #endif
  15. #if defined(BOOST_HAS_PRAGMA_ONCE)
  16. # pragma once
  17. #endif
  18. #include <boost/container/detail/config_begin.hpp>
  19. #include <boost/container/detail/workaround.hpp>
  20. #include <boost/container/detail/type_traits.hpp>
  21. #include <boost/container/vector.hpp>
  22. #include <cstddef>
  23. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  24. #include <initializer_list>
  25. #endif
  26. namespace boost { namespace container {
  27. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  28. namespace dtl {
  29. template<class T, std::size_t N, std::size_t InplaceAlignment, bool ThrowOnOverflow>
  30. class static_storage_allocator
  31. {
  32. typedef bool_<ThrowOnOverflow> throw_on_overflow_t;
  33. static BOOST_NORETURN BOOST_CONTAINER_FORCEINLINE void on_capacity_overflow(true_type)
  34. {
  35. (throw_bad_alloc)();
  36. }
  37. static BOOST_CONTAINER_FORCEINLINE void on_capacity_overflow(false_type)
  38. {
  39. BOOST_ASSERT_MSG(false, "ERROR: static vector capacity overflow");
  40. }
  41. public:
  42. typedef T value_type;
  43. BOOST_CONTAINER_FORCEINLINE static_storage_allocator() BOOST_NOEXCEPT_OR_NOTHROW
  44. {}
  45. BOOST_CONTAINER_FORCEINLINE static_storage_allocator(const static_storage_allocator &) BOOST_NOEXCEPT_OR_NOTHROW
  46. {}
  47. BOOST_CONTAINER_FORCEINLINE static_storage_allocator & operator=(const static_storage_allocator &) BOOST_NOEXCEPT_OR_NOTHROW
  48. { return *this; }
  49. BOOST_CONTAINER_FORCEINLINE T* internal_storage() const BOOST_NOEXCEPT_OR_NOTHROW
  50. { return const_cast<T*>(static_cast<const T*>(static_cast<const void*>(storage.data))); }
  51. BOOST_CONTAINER_FORCEINLINE T* internal_storage() BOOST_NOEXCEPT_OR_NOTHROW
  52. { return static_cast<T*>(static_cast<void*>(storage.data)); }
  53. static const std::size_t internal_capacity = N;
  54. std::size_t max_size() const
  55. { return N; }
  56. static BOOST_CONTAINER_FORCEINLINE void on_capacity_overflow()
  57. {
  58. (on_capacity_overflow)(throw_on_overflow_t());
  59. }
  60. typedef boost::container::dtl::version_type<static_storage_allocator, 0> version;
  61. BOOST_CONTAINER_FORCEINLINE friend bool operator==(const static_storage_allocator &, const static_storage_allocator &) BOOST_NOEXCEPT_OR_NOTHROW
  62. { return false; }
  63. BOOST_CONTAINER_FORCEINLINE friend bool operator!=(const static_storage_allocator &, const static_storage_allocator &) BOOST_NOEXCEPT_OR_NOTHROW
  64. { return true; }
  65. private:
  66. BOOST_STATIC_ASSERT_MSG(!InplaceAlignment || (InplaceAlignment & (InplaceAlignment-1)) == 0, "Alignment option must be zero or power of two");
  67. static const std::size_t final_alignment = InplaceAlignment ? InplaceAlignment : dtl::alignment_of<T>::value;
  68. typename dtl::aligned_storage<sizeof(T)*N, final_alignment>::type storage;
  69. };
  70. template<class Options>
  71. struct get_static_vector_opt
  72. {
  73. typedef Options type;
  74. };
  75. template<>
  76. struct get_static_vector_opt<void>
  77. {
  78. typedef static_vector_null_opt type;
  79. };
  80. template <typename T, std::size_t Capacity, class Options>
  81. struct get_static_vector_allocator
  82. {
  83. typedef typename get_static_vector_opt<Options>::type options_t;
  84. typedef dtl::static_storage_allocator
  85. < T
  86. , Capacity
  87. , options_t::inplace_alignment
  88. , options_t::throw_on_overflow
  89. > type;
  90. };
  91. } //namespace dtl {
  92. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  93. //!
  94. //!@brief A variable-size array container with fixed capacity.
  95. //!
  96. //!static_vector is a sequence container like boost::container::vector with contiguous storage that can
  97. //!change in size, along with the static allocation, low overhead, and fixed capacity of boost::array.
  98. //!
  99. //!A static_vector is a sequence that supports random access to elements, constant time insertion and
  100. //!removal of elements at the end, and linear time insertion and removal of elements at the beginning or
  101. //!in the middle. The number of elements in a static_vector may vary dynamically up to a fixed capacity
  102. //!because elements are stored within the object itself similarly to an array. However, objects are
  103. //!initialized as they are inserted into static_vector unlike C arrays or std::array which must construct
  104. //!all elements on instantiation. The behavior of static_vector enables the use of statically allocated
  105. //!elements in cases with complex object lifetime requirements that would otherwise not be trivially
  106. //!possible.
  107. //!
  108. //!@par Error Handling
  109. //! Insertion beyond the capacity result in throwing std::bad_alloc() if exceptions are enabled or
  110. //! calling throw_bad_alloc() if not enabled.
  111. //!
  112. //! std::out_of_range is thrown if out of bounds access is performed in <code>at()</code> if exceptions are
  113. //! enabled, throw_out_of_range() if not enabled.
  114. //!
  115. //!@tparam T The type of element that will be stored.
  116. //!@tparam Capacity The maximum number of elements static_vector can store, fixed at compile time.
  117. //!@tparam Options A type produced from \c boost::container::static_vector_options.
  118. template <typename T, std::size_t Capacity, class Options BOOST_CONTAINER_DOCONLY(= void) >
  119. class static_vector
  120. : public vector<T, typename dtl::get_static_vector_allocator< T, Capacity, Options>::type>
  121. {
  122. public:
  123. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  124. typedef typename dtl::get_static_vector_allocator< T, Capacity, Options>::type allocator_type;
  125. typedef vector<T, allocator_type > base_t;
  126. BOOST_COPYABLE_AND_MOVABLE(static_vector)
  127. template<class U, std::size_t OtherCapacity, class OtherOptions>
  128. friend class static_vector;
  129. public:
  130. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  131. public:
  132. //! @brief The type of elements stored in the container.
  133. typedef typename base_t::value_type value_type;
  134. //! @brief The unsigned integral type used by the container.
  135. typedef typename base_t::size_type size_type;
  136. //! @brief The pointers difference type.
  137. typedef typename base_t::difference_type difference_type;
  138. //! @brief The pointer type.
  139. typedef typename base_t::pointer pointer;
  140. //! @brief The const pointer type.
  141. typedef typename base_t::const_pointer const_pointer;
  142. //! @brief The value reference type.
  143. typedef typename base_t::reference reference;
  144. //! @brief The value const reference type.
  145. typedef typename base_t::const_reference const_reference;
  146. //! @brief The iterator type.
  147. typedef typename base_t::iterator iterator;
  148. //! @brief The const iterator type.
  149. typedef typename base_t::const_iterator const_iterator;
  150. //! @brief The reverse iterator type.
  151. typedef typename base_t::reverse_iterator reverse_iterator;
  152. //! @brief The const reverse iterator.
  153. typedef typename base_t::const_reverse_iterator const_reverse_iterator;
  154. //! @brief The capacity/max size of the container
  155. static const size_type static_capacity = Capacity;
  156. //! @brief Constructs an empty static_vector.
  157. //!
  158. //! @par Throws
  159. //! Nothing.
  160. //!
  161. //! @par Complexity
  162. //! Constant O(1).
  163. BOOST_CONTAINER_FORCEINLINE static_vector() BOOST_NOEXCEPT_OR_NOTHROW
  164. : base_t()
  165. {}
  166. //! @pre <tt>count <= capacity()</tt>
  167. //!
  168. //! @brief Constructs a static_vector containing count value initialized values.
  169. //!
  170. //! @param count The number of values which will be contained in the container.
  171. //!
  172. //! @par Throws
  173. //! If T's value initialization throws.
  174. //!
  175. //! @par Complexity
  176. //! Linear O(N).
  177. BOOST_CONTAINER_FORCEINLINE explicit static_vector(size_type count)
  178. : base_t(count)
  179. {}
  180. //! @pre <tt>count <= capacity()</tt>
  181. //!
  182. //! @brief Constructs a static_vector containing count default initialized values.
  183. //!
  184. //! @param count The number of values which will be contained in the container.
  185. //!
  186. //! @par Throws
  187. //! If T's default initialization throws.
  188. //!
  189. //! @par Complexity
  190. //! Linear O(N).
  191. //!
  192. //! @par Note
  193. //! Non-standard extension
  194. BOOST_CONTAINER_FORCEINLINE static_vector(size_type count, default_init_t)
  195. : base_t(count, default_init_t())
  196. {}
  197. //! @pre <tt>count <= capacity()</tt>
  198. //!
  199. //! @brief Constructs a static_vector containing count copies of value.
  200. //!
  201. //! @param count The number of copies of a values that will be contained in the container.
  202. //! @param value The value which will be used to copy construct values.
  203. //!
  204. //! @par Throws
  205. //! If T's copy constructor throws.
  206. //!
  207. //! @par Complexity
  208. //! Linear O(N).
  209. BOOST_CONTAINER_FORCEINLINE static_vector(size_type count, value_type const& value)
  210. : base_t(count, value)
  211. {}
  212. //! @pre
  213. //! @li <tt>distance(first, last) <= capacity()</tt>
  214. //! @li Iterator must meet the \c ForwardTraversalIterator concept.
  215. //!
  216. //! @brief Constructs a static_vector containing copy of a range <tt>[first, last)</tt>.
  217. //!
  218. //! @param first The iterator to the first element in range.
  219. //! @param last The iterator to the one after the last element in range.
  220. //!
  221. //! @par Throws
  222. //! If T's constructor taking a dereferenced Iterator throws.
  223. //!
  224. //! @par Complexity
  225. //! Linear O(N).
  226. template <typename Iterator>
  227. BOOST_CONTAINER_FORCEINLINE static_vector(Iterator first, Iterator last)
  228. : base_t(first, last)
  229. {}
  230. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  231. //! @pre
  232. //! @li <tt>distance(il.begin(), il.end()) <= capacity()</tt>
  233. //!
  234. //! @brief Constructs a static_vector containing copy of a range <tt>[il.begin(), il.end())</tt>.
  235. //!
  236. //! @param il std::initializer_list with values to initialize vector.
  237. //!
  238. //! @par Throws
  239. //! If T's constructor taking a dereferenced std::initializer_list throws.
  240. //!
  241. //! @par Complexity
  242. //! Linear O(N).
  243. BOOST_CONTAINER_FORCEINLINE static_vector(std::initializer_list<value_type> il)
  244. : base_t(il)
  245. {}
  246. #endif
  247. //! @brief Constructs a copy of other static_vector.
  248. //!
  249. //! @param other The static_vector which content will be copied to this one.
  250. //!
  251. //! @par Throws
  252. //! If T's copy constructor throws.
  253. //!
  254. //! @par Complexity
  255. //! Linear O(N).
  256. BOOST_CONTAINER_FORCEINLINE static_vector(static_vector const& other)
  257. : base_t(other)
  258. {}
  259. BOOST_CONTAINER_FORCEINLINE static_vector(static_vector const& other, const allocator_type &)
  260. : base_t(other)
  261. {}
  262. BOOST_CONTAINER_FORCEINLINE static_vector(BOOST_RV_REF(static_vector) other, const allocator_type &)
  263. BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_constructible<value_type>::value)
  264. : base_t(BOOST_MOVE_BASE(base_t, other))
  265. {}
  266. BOOST_CONTAINER_FORCEINLINE explicit static_vector(const allocator_type &)
  267. : base_t()
  268. {}
  269. //! @pre <tt>other.size() <= capacity()</tt>.
  270. //!
  271. //! @brief Constructs a copy of other static_vector.
  272. //!
  273. //! @param other The static_vector which content will be copied to this one.
  274. //!
  275. //! @par Throws
  276. //! If T's copy constructor throws.
  277. //!
  278. //! @par Complexity
  279. //! Linear O(N).
  280. template <std::size_t C, class O>
  281. BOOST_CONTAINER_FORCEINLINE static_vector(static_vector<T, C, O> const& other)
  282. : base_t(other)
  283. {}
  284. //! @brief Move constructor. Moves Values stored in the other static_vector to this one.
  285. //!
  286. //! @param other The static_vector which content will be moved to this one.
  287. //!
  288. //! @par Throws
  289. //! @li If \c has_nothrow_move<T>::value is \c true and T's move constructor throws.
  290. //! @li If \c has_nothrow_move<T>::value is \c false and T's copy constructor throws.
  291. //!
  292. //! @par Complexity
  293. //! Linear O(N).
  294. BOOST_CONTAINER_FORCEINLINE static_vector(BOOST_RV_REF(static_vector) other)
  295. BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_constructible<value_type>::value)
  296. : base_t(BOOST_MOVE_BASE(base_t, other))
  297. {}
  298. //! @pre <tt>other.size() <= capacity()</tt>
  299. //!
  300. //! @brief Move constructor. Moves Values stored in the other static_vector to this one.
  301. //!
  302. //! @param other The static_vector which content will be moved to this one.
  303. //!
  304. //! @par Throws
  305. //! @li If \c has_nothrow_move<T>::value is \c true and T's move constructor throws.
  306. //! @li If \c has_nothrow_move<T>::value is \c false and T's copy constructor throws.
  307. //!
  308. //! @par Complexity
  309. //! Linear O(N).
  310. template <std::size_t C, class O>
  311. BOOST_CONTAINER_FORCEINLINE static_vector(BOOST_RV_REF_BEG static_vector<T, C, O> BOOST_RV_REF_END other)
  312. : base_t(BOOST_MOVE_BASE(typename static_vector<T BOOST_MOVE_I C>::base_t, other))
  313. {}
  314. //! @brief Copy assigns Values stored in the other static_vector to this one.
  315. //!
  316. //! @param other The static_vector which content will be copied to this one.
  317. //!
  318. //! @par Throws
  319. //! If T's copy constructor or copy assignment throws.
  320. //!
  321. //! @par Complexity
  322. //! Linear O(N).
  323. BOOST_CONTAINER_FORCEINLINE static_vector & operator=(BOOST_COPY_ASSIGN_REF(static_vector) other)
  324. {
  325. return static_cast<static_vector&>(base_t::operator=(static_cast<base_t const&>(other)));
  326. }
  327. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  328. //! @brief Copy assigns Values stored in std::initializer_list to *this.
  329. //!
  330. //! @param il The std::initializer_list which content will be copied to this one.
  331. //!
  332. //! @par Throws
  333. //! If T's copy constructor or copy assignment throws.
  334. //!
  335. //! @par Complexity
  336. //! Linear O(N).
  337. BOOST_CONTAINER_FORCEINLINE static_vector & operator=(std::initializer_list<value_type> il)
  338. { return static_cast<static_vector&>(base_t::operator=(il)); }
  339. #endif
  340. //! @pre <tt>other.size() <= capacity()</tt>
  341. //!
  342. //! @brief Copy assigns Values stored in the other static_vector to this one.
  343. //!
  344. //! @param other The static_vector which content will be copied to this one.
  345. //!
  346. //! @par Throws
  347. //! If T's copy constructor or copy assignment throws.
  348. //!
  349. //! @par Complexity
  350. //! Linear O(N).
  351. template <std::size_t C, class O>
  352. BOOST_CONTAINER_FORCEINLINE static_vector & operator=(static_vector<T, C, O> const& other)
  353. {
  354. return static_cast<static_vector&>(base_t::operator=
  355. (static_cast<typename static_vector<T, C, O>::base_t const&>(other)));
  356. }
  357. //! @brief Move assignment. Moves Values stored in the other static_vector to this one.
  358. //!
  359. //! @param other The static_vector which content will be moved to this one.
  360. //!
  361. //! @par Throws
  362. //! @li If \c has_nothrow_move<T>::value is \c true and T's move constructor or move assignment throws.
  363. //! @li If \c has_nothrow_move<T>::value is \c false and T's copy constructor or copy assignment throws.
  364. //!
  365. //! @par Complexity
  366. //! Linear O(N).
  367. BOOST_CONTAINER_FORCEINLINE static_vector & operator=(BOOST_RV_REF(static_vector) other)
  368. BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_assignable<value_type>::value)
  369. {
  370. return static_cast<static_vector&>(base_t::operator=(BOOST_MOVE_BASE(base_t, other)));
  371. }
  372. //! @pre <tt>other.size() <= capacity()</tt>
  373. //!
  374. //! @brief Move assignment. Moves Values stored in the other static_vector to this one.
  375. //!
  376. //! @param other The static_vector which content will be moved to this one.
  377. //!
  378. //! @par Throws
  379. //! @li If \c has_nothrow_move<T>::value is \c true and T's move constructor or move assignment throws.
  380. //! @li If \c has_nothrow_move<T>::value is \c false and T's copy constructor or copy assignment throws.
  381. //!
  382. //! @par Complexity
  383. //! Linear O(N).
  384. template <std::size_t C, class O>
  385. BOOST_CONTAINER_FORCEINLINE static_vector & operator=(BOOST_RV_REF_BEG static_vector<T, C, O> BOOST_RV_REF_END other)
  386. {
  387. return static_cast<static_vector&>(base_t::operator=
  388. (BOOST_MOVE_BASE(typename static_vector<T BOOST_MOVE_I C>::base_t, other)));
  389. }
  390. #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  391. //! @brief Destructor. Destroys Values stored in this container.
  392. //!
  393. //! @par Throws
  394. //! Nothing
  395. //!
  396. //! @par Complexity
  397. //! Linear O(N).
  398. ~static_vector();
  399. //! @brief Swaps contents of the other static_vector and this one.
  400. //!
  401. //! @param other The static_vector which content will be swapped with this one's content.
  402. //!
  403. //! @par Throws
  404. //! @li If \c has_nothrow_move<T>::value is \c true and T's move constructor or move assignment throws,
  405. //! @li If \c has_nothrow_move<T>::value is \c false and T's copy constructor or copy assignment throws,
  406. //!
  407. //! @par Complexity
  408. //! Linear O(N).
  409. void swap(static_vector & other);
  410. //! @pre <tt>other.size() <= capacity() && size() <= other.capacity()</tt>
  411. //!
  412. //! @brief Swaps contents of the other static_vector and this one.
  413. //!
  414. //! @param other The static_vector which content will be swapped with this one's content.
  415. //!
  416. //! @par Throws
  417. //! @li If \c has_nothrow_move<T>::value is \c true and T's move constructor or move assignment throws,
  418. //! @li If \c has_nothrow_move<T>::value is \c false and T's copy constructor or copy assignment throws,
  419. //!
  420. //! @par Complexity
  421. //! Linear O(N).
  422. template <std::size_t C, class O>
  423. void swap(static_vector<T, C, O> & other);
  424. //! @pre <tt>count <= capacity()</tt>
  425. //!
  426. //! @brief Inserts or erases elements at the end such that
  427. //! the size becomes count. New elements are value initialized.
  428. //!
  429. //! @param count The number of elements which will be stored in the container.
  430. //!
  431. //! @par Throws
  432. //! If T's value initialization throws.
  433. //!
  434. //! @par Complexity
  435. //! Linear O(N).
  436. void resize(size_type count);
  437. //! @pre <tt>count <= capacity()</tt>
  438. //!
  439. //! @brief Inserts or erases elements at the end such that
  440. //! the size becomes count. New elements are default initialized.
  441. //!
  442. //! @param count The number of elements which will be stored in the container.
  443. //!
  444. //! @par Throws
  445. //! If T's default initialization throws.
  446. //!
  447. //! @par Complexity
  448. //! Linear O(N).
  449. //!
  450. //! @par Note
  451. //! Non-standard extension
  452. void resize(size_type count, default_init_t);
  453. //! @pre <tt>count <= capacity()</tt>
  454. //!
  455. //! @brief Inserts or erases elements at the end such that
  456. //! the size becomes count. New elements are copy constructed from value.
  457. //!
  458. //! @param count The number of elements which will be stored in the container.
  459. //! @param value The value used to copy construct the new element.
  460. //!
  461. //! @par Throws
  462. //! If T's copy constructor throws.
  463. //!
  464. //! @par Complexity
  465. //! Linear O(N).
  466. void resize(size_type count, value_type const& value);
  467. //! @pre <tt>count <= capacity()</tt>
  468. //!
  469. //! @brief This call has no effect because the Capacity of this container is constant.
  470. //!
  471. //! @param count The number of elements which the container should be able to contain.
  472. //!
  473. //! @par Throws
  474. //! Nothing.
  475. //!
  476. //! @par Complexity
  477. //! Linear O(N).
  478. void reserve(size_type count) BOOST_NOEXCEPT_OR_NOTHROW;
  479. //! @pre <tt>size() < capacity()</tt>
  480. //!
  481. //! @brief Adds a copy of value at the end.
  482. //!
  483. //! @param value The value used to copy construct the new element.
  484. //!
  485. //! @par Throws
  486. //! If T's copy constructor throws.
  487. //!
  488. //! @par Complexity
  489. //! Constant O(1).
  490. void push_back(value_type const& value);
  491. //! @pre <tt>size() < capacity()</tt>
  492. //!
  493. //! @brief Moves value to the end.
  494. //!
  495. //! @param value The value to move construct the new element.
  496. //!
  497. //! @par Throws
  498. //! If T's move constructor throws.
  499. //!
  500. //! @par Complexity
  501. //! Constant O(1).
  502. void push_back(BOOST_RV_REF(value_type) value);
  503. //! @pre <tt>!empty()</tt>
  504. //!
  505. //! @brief Destroys last value and decreases the size.
  506. //!
  507. //! @par Throws
  508. //! Nothing by default.
  509. //!
  510. //! @par Complexity
  511. //! Constant O(1).
  512. void pop_back();
  513. //! @pre
  514. //! @li \c p must be a valid iterator of \c *this in range <tt>[begin(), end()]</tt>.
  515. //! @li <tt>size() < capacity()</tt>
  516. //!
  517. //! @brief Inserts a copy of element at p.
  518. //!
  519. //! @param p The position at which the new value will be inserted.
  520. //! @param value The value used to copy construct the new element.
  521. //!
  522. //! @par Throws
  523. //! @li If T's copy constructor or copy assignment throws
  524. //! @li If T's move constructor or move assignment throws.
  525. //!
  526. //! @par Complexity
  527. //! Constant or linear.
  528. iterator insert(const_iterator p, value_type const& value);
  529. //! @pre
  530. //! @li \c p must be a valid iterator of \c *this in range <tt>[begin(), end()]</tt>.
  531. //! @li <tt>size() < capacity()</tt>
  532. //!
  533. //! @brief Inserts a move-constructed element at p.
  534. //!
  535. //! @param p The position at which the new value will be inserted.
  536. //! @param value The value used to move construct the new element.
  537. //!
  538. //! @par Throws
  539. //! If T's move constructor or move assignment throws.
  540. //!
  541. //! @par Complexity
  542. //! Constant or linear.
  543. iterator insert(const_iterator p, BOOST_RV_REF(value_type) value);
  544. //! @pre
  545. //! @li \c p must be a valid iterator of \c *this in range <tt>[begin(), end()]</tt>.
  546. //! @li <tt>size() + count <= capacity()</tt>
  547. //!
  548. //! @brief Inserts a count copies of value at p.
  549. //!
  550. //! @param p The position at which new elements will be inserted.
  551. //! @param count The number of new elements which will be inserted.
  552. //! @param value The value used to copy construct new elements.
  553. //!
  554. //! @par Throws
  555. //! @li If T's copy constructor or copy assignment throws.
  556. //! @li If T's move constructor or move assignment throws.
  557. //!
  558. //! @par Complexity
  559. //! Linear O(N).
  560. iterator insert(const_iterator p, size_type count, value_type const& value);
  561. //! @pre
  562. //! @li \c p must be a valid iterator of \c *this in range <tt>[begin(), end()]</tt>.
  563. //! @li <tt>distance(first, last) <= capacity()</tt>
  564. //! @li \c Iterator must meet the \c ForwardTraversalIterator concept.
  565. //!
  566. //! @brief Inserts a copy of a range <tt>[first, last)</tt> at p.
  567. //!
  568. //! @param p The position at which new elements will be inserted.
  569. //! @param first The iterator to the first element of a range used to construct new elements.
  570. //! @param last The iterator to the one after the last element of a range used to construct new elements.
  571. //!
  572. //! @par Throws
  573. //! @li If T's constructor and assignment taking a dereferenced \c Iterator.
  574. //! @li If T's move constructor or move assignment throws.
  575. //!
  576. //! @par Complexity
  577. //! Linear O(N).
  578. template <typename Iterator>
  579. iterator insert(const_iterator p, Iterator first, Iterator last);
  580. //! @pre
  581. //! @li \c p must be a valid iterator of \c *this in range <tt>[begin(), end()]</tt>.
  582. //! @li <tt>distance(il.begin(), il.end()) <= capacity()</tt>
  583. //!
  584. //! @brief Inserts a copy of a range <tt>[il.begin(), il.end())</tt> at p.
  585. //!
  586. //! @param p The position at which new elements will be inserted.
  587. //! @param il The std::initializer_list which contains elements that will be inserted.
  588. //!
  589. //! @par Throws
  590. //! @li If T's constructor and assignment taking a dereferenced std::initializer_list iterator.
  591. //!
  592. //! @par Complexity
  593. //! Linear O(N).
  594. iterator insert(const_iterator p, std::initializer_list<value_type> il);
  595. //! @pre \c p must be a valid iterator of \c *this in range <tt>[begin(), end())</tt>
  596. //!
  597. //! @brief Erases T from p.
  598. //!
  599. //! @param p The position of the element which will be erased from the container.
  600. //!
  601. //! @par Throws
  602. //! If T's move assignment throws.
  603. //!
  604. //! @par Complexity
  605. //! Linear O(N).
  606. iterator erase(const_iterator p);
  607. //! @pre
  608. //! @li \c first and \c last must define a valid range
  609. //! @li iterators must be in range <tt>[begin(), end()]</tt>
  610. //!
  611. //! @brief Erases Values from a range <tt>[first, last)</tt>.
  612. //!
  613. //! @param first The position of the first element of a range which will be erased from the container.
  614. //! @param last The position of the one after the last element of a range which will be erased from the container.
  615. //!
  616. //! @par Throws
  617. //! If T's move assignment throws.
  618. //!
  619. //! @par Complexity
  620. //! Linear O(N).
  621. iterator erase(const_iterator first, const_iterator last);
  622. //! @pre <tt>distance(first, last) <= capacity()</tt>
  623. //!
  624. //! @brief Assigns a range <tt>[first, last)</tt> of Values to this container.
  625. //!
  626. //! @param first The iterator to the first element of a range used to construct new content of this container.
  627. //! @param last The iterator to the one after the last element of a range used to construct new content of this container.
  628. //!
  629. //! @par Throws
  630. //! If T's copy constructor or copy assignment throws,
  631. //!
  632. //! @par Complexity
  633. //! Linear O(N).
  634. template <typename Iterator>
  635. void assign(Iterator first, Iterator last);
  636. //! @pre <tt>distance(il.begin(), il.end()) <= capacity()</tt>
  637. //!
  638. //! @brief Assigns a range <tt>[il.begin(), il.end())</tt> of Values to this container.
  639. //!
  640. //! @param il std::initializer_list with values used to construct new content of this container.
  641. //!
  642. //! @par Throws
  643. //! If T's copy constructor or copy assignment throws,
  644. //!
  645. //! @par Complexity
  646. //! Linear O(N).
  647. void assign(std::initializer_list<value_type> il);
  648. //! @pre <tt>count <= capacity()</tt>
  649. //!
  650. //! @brief Assigns a count copies of value to this container.
  651. //!
  652. //! @param count The new number of elements which will be container in the container.
  653. //! @param value The value which will be used to copy construct the new content.
  654. //!
  655. //! @par Throws
  656. //! If T's copy constructor or copy assignment throws.
  657. //!
  658. //! @par Complexity
  659. //! Linear O(N).
  660. void assign(size_type count, value_type const& value);
  661. //! @pre <tt>size() < capacity()</tt>
  662. //!
  663. //! @brief Inserts a T constructed with
  664. //! \c std::forward<Args>(args)... in the end of the container.
  665. //!
  666. //! @return A reference to the created object.
  667. //!
  668. //! @param args The arguments of the constructor of the new element which will be created at the end of the container.
  669. //!
  670. //! @par Throws
  671. //! If in-place constructor throws or T's move constructor throws.
  672. //!
  673. //! @par Complexity
  674. //! Constant O(1).
  675. template<class ...Args>
  676. reference emplace_back(Args &&...args);
  677. //! @pre
  678. //! @li \c p must be a valid iterator of \c *this in range <tt>[begin(), end()]</tt>
  679. //! @li <tt>size() < capacity()</tt>
  680. //!
  681. //! @brief Inserts a T constructed with
  682. //! \c std::forward<Args>(args)... before p
  683. //!
  684. //! @param p The position at which new elements will be inserted.
  685. //! @param args The arguments of the constructor of the new element.
  686. //!
  687. //! @par Throws
  688. //! If in-place constructor throws or if T's move constructor or move assignment throws.
  689. //!
  690. //! @par Complexity
  691. //! Constant or linear.
  692. template<class ...Args>
  693. iterator emplace(const_iterator p, Args &&...args);
  694. //! @brief Removes all elements from the container.
  695. //!
  696. //! @par Throws
  697. //! Nothing.
  698. //!
  699. //! @par Complexity
  700. //! Constant O(1).
  701. void clear() BOOST_NOEXCEPT_OR_NOTHROW;
  702. //! @pre <tt>i < size()</tt>
  703. //!
  704. //! @brief Returns reference to the i-th element.
  705. //!
  706. //! @param i The element's index.
  707. //!
  708. //! @return reference to the i-th element
  709. //! from the beginning of the container.
  710. //!
  711. //! @par Throws
  712. //! \c std::out_of_range exception by default.
  713. //!
  714. //! @par Complexity
  715. //! Constant O(1).
  716. reference at(size_type i);
  717. //! @pre <tt>i < size()</tt>
  718. //!
  719. //! @brief Returns const reference to the i-th element.
  720. //!
  721. //! @param i The element's index.
  722. //!
  723. //! @return const reference to the i-th element
  724. //! from the beginning of the container.
  725. //!
  726. //! @par Throws
  727. //! \c std::out_of_range exception by default.
  728. //!
  729. //! @par Complexity
  730. //! Constant O(1).
  731. const_reference at(size_type i) const;
  732. //! @pre <tt>i < size()</tt>
  733. //!
  734. //! @brief Returns reference to the i-th element.
  735. //!
  736. //! @param i The element's index.
  737. //!
  738. //! @return reference to the i-th element
  739. //! from the beginning of the container.
  740. //!
  741. //! @par Throws
  742. //! Nothing by default.
  743. //!
  744. //! @par Complexity
  745. //! Constant O(1).
  746. reference operator[](size_type i);
  747. //! @pre <tt>i < size()</tt>
  748. //!
  749. //! @brief Returns const reference to the i-th element.
  750. //!
  751. //! @param i The element's index.
  752. //!
  753. //! @return const reference to the i-th element
  754. //! from the beginning of the container.
  755. //!
  756. //! @par Throws
  757. //! Nothing by default.
  758. //!
  759. //! @par Complexity
  760. //! Constant O(1).
  761. const_reference operator[](size_type i) const;
  762. //! @pre <tt>i =< size()</tt>
  763. //!
  764. //! @brief Returns a iterator to the i-th element.
  765. //!
  766. //! @param i The element's index.
  767. //!
  768. //! @return a iterator to the i-th element.
  769. //!
  770. //! @par Throws
  771. //! Nothing by default.
  772. //!
  773. //! @par Complexity
  774. //! Constant O(1).
  775. iterator nth(size_type i);
  776. //! @pre <tt>i =< size()</tt>
  777. //!
  778. //! @brief Returns a const_iterator to the i-th element.
  779. //!
  780. //! @param i The element's index.
  781. //!
  782. //! @return a const_iterator to the i-th element.
  783. //!
  784. //! @par Throws
  785. //! Nothing by default.
  786. //!
  787. //! @par Complexity
  788. //! Constant O(1).
  789. const_iterator nth(size_type i) const;
  790. //! @pre <tt>begin() <= p <= end()</tt>
  791. //!
  792. //! @brief Returns the index of the element pointed by p.
  793. //!
  794. //! @param p An iterator to the element.
  795. //!
  796. //! @return The index of the element pointed by p.
  797. //!
  798. //! @par Throws
  799. //! Nothing by default.
  800. //!
  801. //! @par Complexity
  802. //! Constant O(1).
  803. size_type index_of(iterator p);
  804. //! @pre <tt>begin() <= p <= end()</tt>
  805. //!
  806. //! @brief Returns the index of the element pointed by p.
  807. //!
  808. //! @param p A const_iterator to the element.
  809. //!
  810. //! @return a const_iterator to the i-th element.
  811. //!
  812. //! @par Throws
  813. //! Nothing by default.
  814. //!
  815. //! @par Complexity
  816. //! Constant O(1).
  817. size_type index_of(const_iterator p) const;
  818. //! @pre \c !empty()
  819. //!
  820. //! @brief Returns reference to the first element.
  821. //!
  822. //! @return reference to the first element
  823. //! from the beginning of the container.
  824. //!
  825. //! @par Throws
  826. //! Nothing by default.
  827. //!
  828. //! @par Complexity
  829. //! Constant O(1).
  830. reference front();
  831. //! @pre \c !empty()
  832. //!
  833. //! @brief Returns const reference to the first element.
  834. //!
  835. //! @return const reference to the first element
  836. //! from the beginning of the container.
  837. //!
  838. //! @par Throws
  839. //! Nothing by default.
  840. //!
  841. //! @par Complexity
  842. //! Constant O(1).
  843. const_reference front() const;
  844. //! @pre \c !empty()
  845. //!
  846. //! @brief Returns reference to the last element.
  847. //!
  848. //! @return reference to the last element
  849. //! from the beginning of the container.
  850. //!
  851. //! @par Throws
  852. //! Nothing by default.
  853. //!
  854. //! @par Complexity
  855. //! Constant O(1).
  856. reference back();
  857. //! @pre \c !empty()
  858. //!
  859. //! @brief Returns const reference to the first element.
  860. //!
  861. //! @return const reference to the last element
  862. //! from the beginning of the container.
  863. //!
  864. //! @par Throws
  865. //! Nothing by default.
  866. //!
  867. //! @par Complexity
  868. //! Constant O(1).
  869. const_reference back() const;
  870. //! @brief Pointer such that <tt>[data(), data() + size())</tt> is a valid range.
  871. //! For a non-empty vector <tt>data() == &front()</tt>.
  872. //!
  873. //! @par Throws
  874. //! Nothing.
  875. //!
  876. //! @par Complexity
  877. //! Constant O(1).
  878. T * data() BOOST_NOEXCEPT_OR_NOTHROW;
  879. //! @brief Const pointer such that <tt>[data(), data() + size())</tt> is a valid range.
  880. //! For a non-empty vector <tt>data() == &front()</tt>.
  881. //!
  882. //! @par Throws
  883. //! Nothing.
  884. //!
  885. //! @par Complexity
  886. //! Constant O(1).
  887. const T * data() const BOOST_NOEXCEPT_OR_NOTHROW;
  888. //! @brief Returns iterator to the first element.
  889. //!
  890. //! @return iterator to the first element contained in the vector.
  891. //!
  892. //! @par Throws
  893. //! Nothing.
  894. //!
  895. //! @par Complexity
  896. //! Constant O(1).
  897. iterator begin() BOOST_NOEXCEPT_OR_NOTHROW;
  898. //! @brief Returns const iterator to the first element.
  899. //!
  900. //! @return const_iterator to the first element contained in the vector.
  901. //!
  902. //! @par Throws
  903. //! Nothing.
  904. //!
  905. //! @par Complexity
  906. //! Constant O(1).
  907. const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW;
  908. //! @brief Returns const iterator to the first element.
  909. //!
  910. //! @return const_iterator to the first element contained in the vector.
  911. //!
  912. //! @par Throws
  913. //! Nothing.
  914. //!
  915. //! @par Complexity
  916. //! Constant O(1).
  917. const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  918. //! @brief Returns iterator to the one after the last element.
  919. //!
  920. //! @return iterator pointing to the one after the last element contained in the vector.
  921. //!
  922. //! @par Throws
  923. //! Nothing.
  924. //!
  925. //! @par Complexity
  926. //! Constant O(1).
  927. iterator end() BOOST_NOEXCEPT_OR_NOTHROW;
  928. //! @brief Returns const iterator to the one after the last element.
  929. //!
  930. //! @return const_iterator pointing to the one after the last element contained in the vector.
  931. //!
  932. //! @par Throws
  933. //! Nothing.
  934. //!
  935. //! @par Complexity
  936. //! Constant O(1).
  937. const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW;
  938. //! @brief Returns const iterator to the one after the last element.
  939. //!
  940. //! @return const_iterator pointing to the one after the last element contained in the vector.
  941. //!
  942. //! @par Throws
  943. //! Nothing.
  944. //!
  945. //! @par Complexity
  946. //! Constant O(1).
  947. const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW;
  948. //! @brief Returns reverse iterator to the first element of the reversed container.
  949. //!
  950. //! @return reverse_iterator pointing to the beginning
  951. //! of the reversed static_vector.
  952. //!
  953. //! @par Throws
  954. //! Nothing.
  955. //!
  956. //! @par Complexity
  957. //! Constant O(1).
  958. reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW;
  959. //! @brief Returns const reverse iterator to the first element of the reversed container.
  960. //!
  961. //! @return const_reverse_iterator pointing to the beginning
  962. //! of the reversed static_vector.
  963. //!
  964. //! @par Throws
  965. //! Nothing.
  966. //!
  967. //! @par Complexity
  968. //! Constant O(1).
  969. const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  970. //! @brief Returns const reverse iterator to the first element of the reversed container.
  971. //!
  972. //! @return const_reverse_iterator pointing to the beginning
  973. //! of the reversed static_vector.
  974. //!
  975. //! @par Throws
  976. //! Nothing.
  977. //!
  978. //! @par Complexity
  979. //! Constant O(1).
  980. const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  981. //! @brief Returns reverse iterator to the one after the last element of the reversed container.
  982. //!
  983. //! @return reverse_iterator pointing to the one after the last element
  984. //! of the reversed static_vector.
  985. //!
  986. //! @par Throws
  987. //! Nothing.
  988. //!
  989. //! @par Complexity
  990. //! Constant O(1).
  991. reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW;
  992. //! @brief Returns const reverse iterator to the one after the last element of the reversed container.
  993. //!
  994. //! @return const_reverse_iterator pointing to the one after the last element
  995. //! of the reversed static_vector.
  996. //!
  997. //! @par Throws
  998. //! Nothing.
  999. //!
  1000. //! @par Complexity
  1001. //! Constant O(1).
  1002. const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW;
  1003. //! @brief Returns const reverse iterator to the one after the last element of the reversed container.
  1004. //!
  1005. //! @return const_reverse_iterator pointing to the one after the last element
  1006. //! of the reversed static_vector.
  1007. //!
  1008. //! @par Throws
  1009. //! Nothing.
  1010. //!
  1011. //! @par Complexity
  1012. //! Constant O(1).
  1013. const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW;
  1014. //! @brief Returns container's capacity.
  1015. //!
  1016. //! @return container's capacity.
  1017. //!
  1018. //! @par Throws
  1019. //! Nothing.
  1020. //!
  1021. //! @par Complexity
  1022. //! Constant O(1).
  1023. static size_type capacity() BOOST_NOEXCEPT_OR_NOTHROW;
  1024. //! @brief Returns container's capacity.
  1025. //!
  1026. //! @return container's capacity.
  1027. //!
  1028. //! @par Throws
  1029. //! Nothing.
  1030. //!
  1031. //! @par Complexity
  1032. //! Constant O(1).
  1033. static size_type max_size() BOOST_NOEXCEPT_OR_NOTHROW;
  1034. //! @brief Returns the number of stored elements.
  1035. //!
  1036. //! @return Number of elements contained in the container.
  1037. //!
  1038. //! @par Throws
  1039. //! Nothing.
  1040. //!
  1041. //! @par Complexity
  1042. //! Constant O(1).
  1043. size_type size() const BOOST_NOEXCEPT_OR_NOTHROW;
  1044. //! @brief Queries if the container contains elements.
  1045. //!
  1046. //! @return true if the number of elements contained in the
  1047. //! container is equal to 0.
  1048. //!
  1049. //! @par Throws
  1050. //! Nothing.
  1051. //!
  1052. //! @par Complexity
  1053. //! Constant O(1).
  1054. bool empty() const BOOST_NOEXCEPT_OR_NOTHROW;
  1055. #else
  1056. BOOST_CONTAINER_FORCEINLINE friend void swap(static_vector &x, static_vector &y)
  1057. {
  1058. x.swap(y);
  1059. }
  1060. #endif // BOOST_CONTAINER_DOXYGEN_INVOKED
  1061. };
  1062. #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  1063. //! @brief Checks if contents of two static_vectors are equal.
  1064. //!
  1065. //! @ingroup static_vector_non_member
  1066. //!
  1067. //! @param x The first static_vector.
  1068. //! @param y The second static_vector.
  1069. //!
  1070. //! @return \c true if containers have the same size and elements in both containers are equal.
  1071. //!
  1072. //! @par Complexity
  1073. //! Linear O(N).
  1074. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1075. bool operator== (static_vector<V, C1, O1> const& x, static_vector<V, C2, O2> const& y);
  1076. //! @brief Checks if contents of two static_vectors are not equal.
  1077. //!
  1078. //! @ingroup static_vector_non_member
  1079. //!
  1080. //! @param x The first static_vector.
  1081. //! @param y The second static_vector.
  1082. //!
  1083. //! @return \c true if containers have different size or elements in both containers are not equal.
  1084. //!
  1085. //! @par Complexity
  1086. //! Linear O(N).
  1087. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1088. bool operator!= (static_vector<V, C1, O1> const& x, static_vector<V, C2, O2> const& y);
  1089. //! @brief Lexicographically compares static_vectors.
  1090. //!
  1091. //! @ingroup static_vector_non_member
  1092. //!
  1093. //! @param x The first static_vector.
  1094. //! @param y The second static_vector.
  1095. //!
  1096. //! @return \c true if x compares lexicographically less than y.
  1097. //!
  1098. //! @par Complexity
  1099. //! Linear O(N).
  1100. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1101. bool operator< (static_vector<V, C1, O1> const& x, static_vector<V, C2, O2> const& y);
  1102. //! @brief Lexicographically compares static_vectors.
  1103. //!
  1104. //! @ingroup static_vector_non_member
  1105. //!
  1106. //! @param x The first static_vector.
  1107. //! @param y The second static_vector.
  1108. //!
  1109. //! @return \c true if y compares lexicographically less than x.
  1110. //!
  1111. //! @par Complexity
  1112. //! Linear O(N).
  1113. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1114. bool operator> (static_vector<V, C1, O1> const& x, static_vector<V, C2, O2> const& y);
  1115. //! @brief Lexicographically compares static_vectors.
  1116. //!
  1117. //! @ingroup static_vector_non_member
  1118. //!
  1119. //! @param x The first static_vector.
  1120. //! @param y The second static_vector.
  1121. //!
  1122. //! @return \c true if y don't compare lexicographically less than x.
  1123. //!
  1124. //! @par Complexity
  1125. //! Linear O(N).
  1126. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1127. bool operator<= (static_vector<V, C1, O1> const& x, static_vector<V, C2, O2> const& y);
  1128. //! @brief Lexicographically compares static_vectors.
  1129. //!
  1130. //! @ingroup static_vector_non_member
  1131. //!
  1132. //! @param x The first static_vector.
  1133. //! @param y The second static_vector.
  1134. //!
  1135. //! @return \c true if x don't compare lexicographically less than y.
  1136. //!
  1137. //! @par Complexity
  1138. //! Linear O(N).
  1139. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1140. bool operator>= (static_vector<V, C1, O1> const& x, static_vector<V, C2, O2> const& y);
  1141. //! @brief Swaps contents of two static_vectors.
  1142. //!
  1143. //! This function calls static_vector::swap().
  1144. //!
  1145. //! @ingroup static_vector_non_member
  1146. //!
  1147. //! @param x The first static_vector.
  1148. //! @param y The second static_vector.
  1149. //!
  1150. //! @par Complexity
  1151. //! Linear O(N).
  1152. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1153. inline void swap(static_vector<V, C1, O1> & x, static_vector<V, C2, O2> & y);
  1154. #else
  1155. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1156. inline void swap(static_vector<V, C1, O1> & x, static_vector<V, C2, O2> & y
  1157. , typename dtl::enable_if_c< C1 != C2>::type * = 0)
  1158. {
  1159. x.swap(y);
  1160. }
  1161. #endif // BOOST_CONTAINER_DOXYGEN_INVOKED
  1162. }} // namespace boost::container
  1163. #include <boost/container/detail/config_end.hpp>
  1164. #endif // BOOST_CONTAINER_STATIC_VECTOR_HPP