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