static_vector.hpp 45 KB

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