static_vector.hpp 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  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. #endif //#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  1015. //! @brief Returns container's capacity.
  1016. //!
  1017. //! @return container's capacity.
  1018. //!
  1019. //! @par Throws
  1020. //! Nothing.
  1021. //!
  1022. //! @par Complexity
  1023. //! Constant O(1).
  1024. BOOST_CONTAINER_FORCEINLINE static size_type capacity() BOOST_NOEXCEPT_OR_NOTHROW
  1025. { return static_capacity; }
  1026. //! @brief Returns container's capacity.
  1027. //!
  1028. //! @return container's capacity.
  1029. //!
  1030. //! @par Throws
  1031. //! Nothing.
  1032. //!
  1033. //! @par Complexity
  1034. //! Constant O(1).
  1035. BOOST_CONTAINER_FORCEINLINE static size_type max_size() BOOST_NOEXCEPT_OR_NOTHROW
  1036. { return static_capacity; }
  1037. #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  1038. //! @brief Returns the number of stored elements.
  1039. //!
  1040. //! @return Number of elements contained in the container.
  1041. //!
  1042. //! @par Throws
  1043. //! Nothing.
  1044. //!
  1045. //! @par Complexity
  1046. //! Constant O(1).
  1047. size_type size() const BOOST_NOEXCEPT_OR_NOTHROW;
  1048. //! @brief Queries if the container contains elements.
  1049. //!
  1050. //! @return true if the number of elements contained in the
  1051. //! container is equal to 0.
  1052. //!
  1053. //! @par Throws
  1054. //! Nothing.
  1055. //!
  1056. //! @par Complexity
  1057. //! Constant O(1).
  1058. bool empty() const BOOST_NOEXCEPT_OR_NOTHROW;
  1059. #else
  1060. BOOST_CONTAINER_FORCEINLINE friend void swap(static_vector &x, static_vector &y)
  1061. {
  1062. x.swap(y);
  1063. }
  1064. #endif // BOOST_CONTAINER_DOXYGEN_INVOKED
  1065. };
  1066. #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  1067. //! @brief Checks if contents of two static_vectors are equal.
  1068. //!
  1069. //! @ingroup static_vector_non_member
  1070. //!
  1071. //! @param x The first static_vector.
  1072. //! @param y The second static_vector.
  1073. //!
  1074. //! @return \c true if containers have the same size and elements in both containers are equal.
  1075. //!
  1076. //! @par Complexity
  1077. //! Linear O(N).
  1078. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1079. bool operator== (static_vector<V, C1, O1> const& x, static_vector<V, C2, O2> const& y);
  1080. //! @brief Checks if contents of two static_vectors are not equal.
  1081. //!
  1082. //! @ingroup static_vector_non_member
  1083. //!
  1084. //! @param x The first static_vector.
  1085. //! @param y The second static_vector.
  1086. //!
  1087. //! @return \c true if containers have different size or elements in both containers are not equal.
  1088. //!
  1089. //! @par Complexity
  1090. //! Linear O(N).
  1091. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1092. bool operator!= (static_vector<V, C1, O1> const& x, static_vector<V, C2, O2> const& y);
  1093. //! @brief Lexicographically compares static_vectors.
  1094. //!
  1095. //! @ingroup static_vector_non_member
  1096. //!
  1097. //! @param x The first static_vector.
  1098. //! @param y The second static_vector.
  1099. //!
  1100. //! @return \c true if x compares lexicographically less than y.
  1101. //!
  1102. //! @par Complexity
  1103. //! Linear O(N).
  1104. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1105. bool operator< (static_vector<V, C1, O1> const& x, static_vector<V, C2, O2> const& y);
  1106. //! @brief Lexicographically compares static_vectors.
  1107. //!
  1108. //! @ingroup static_vector_non_member
  1109. //!
  1110. //! @param x The first static_vector.
  1111. //! @param y The second static_vector.
  1112. //!
  1113. //! @return \c true if y compares lexicographically less than x.
  1114. //!
  1115. //! @par Complexity
  1116. //! Linear O(N).
  1117. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1118. bool operator> (static_vector<V, C1, O1> const& x, static_vector<V, C2, O2> const& y);
  1119. //! @brief Lexicographically compares static_vectors.
  1120. //!
  1121. //! @ingroup static_vector_non_member
  1122. //!
  1123. //! @param x The first static_vector.
  1124. //! @param y The second static_vector.
  1125. //!
  1126. //! @return \c true if y don't compare lexicographically less than x.
  1127. //!
  1128. //! @par Complexity
  1129. //! Linear O(N).
  1130. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1131. bool operator<= (static_vector<V, C1, O1> const& x, static_vector<V, C2, O2> const& y);
  1132. //! @brief Lexicographically compares static_vectors.
  1133. //!
  1134. //! @ingroup static_vector_non_member
  1135. //!
  1136. //! @param x The first static_vector.
  1137. //! @param y The second static_vector.
  1138. //!
  1139. //! @return \c true if x don't compare lexicographically less than y.
  1140. //!
  1141. //! @par Complexity
  1142. //! Linear O(N).
  1143. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1144. bool operator>= (static_vector<V, C1, O1> const& x, static_vector<V, C2, O2> const& y);
  1145. //! @brief Swaps contents of two static_vectors.
  1146. //!
  1147. //! This function calls static_vector::swap().
  1148. //!
  1149. //! @ingroup static_vector_non_member
  1150. //!
  1151. //! @param x The first static_vector.
  1152. //! @param y The second static_vector.
  1153. //!
  1154. //! @par Complexity
  1155. //! Linear O(N).
  1156. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1157. inline void swap(static_vector<V, C1, O1> & x, static_vector<V, C2, O2> & y);
  1158. #else
  1159. template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
  1160. inline void swap(static_vector<V, C1, O1> & x, static_vector<V, C2, O2> & y
  1161. , typename dtl::enable_if_c< C1 != C2>::type * = 0)
  1162. {
  1163. x.swap(y);
  1164. }
  1165. #endif // BOOST_CONTAINER_DOXYGEN_INVOKED
  1166. }} // namespace boost::container
  1167. #include <boost/container/detail/config_end.hpp>
  1168. #endif // BOOST_CONTAINER_STATIC_VECTOR_HPP