1 // Boost.Container static_vector
3 // Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland.
4 // Copyright (c) 2011-2013 Andrew Hundt.
5 // Copyright (c) 2013-2014 Ion Gaztanaga
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)
11 #ifndef BOOST_CONTAINER_STATIC_VECTOR_HPP
12 #define BOOST_CONTAINER_STATIC_VECTOR_HPP
14 #ifndef BOOST_CONFIG_HPP
15 # include <boost/config.hpp>
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
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>
28 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
29 #include <initializer_list>
32 namespace boost { namespace container {
34 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
36 namespace container_detail {
38 template<class T, std::size_t N>
39 class static_storage_allocator
44 BOOST_CONTAINER_FORCEINLINE static_storage_allocator() BOOST_NOEXCEPT_OR_NOTHROW
47 BOOST_CONTAINER_FORCEINLINE static_storage_allocator(const static_storage_allocator &) BOOST_NOEXCEPT_OR_NOTHROW
50 BOOST_CONTAINER_FORCEINLINE static_storage_allocator & operator=(const static_storage_allocator &) BOOST_NOEXCEPT_OR_NOTHROW
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))); }
56 BOOST_CONTAINER_FORCEINLINE T* internal_storage() BOOST_NOEXCEPT_OR_NOTHROW
57 { return static_cast<T*>(static_cast<void*>(&storage)); }
59 static const std::size_t internal_capacity = N;
61 std::size_t max_size() const
64 typedef boost::container::container_detail::version_type<static_storage_allocator, 0> version;
66 BOOST_CONTAINER_FORCEINLINE friend bool operator==(const static_storage_allocator &, const static_storage_allocator &) BOOST_NOEXCEPT_OR_NOTHROW
69 BOOST_CONTAINER_FORCEINLINE friend bool operator!=(const static_storage_allocator &, const static_storage_allocator &) BOOST_NOEXCEPT_OR_NOTHROW
73 typename aligned_storage<sizeof(T)*N, alignment_of<T>::value>::type storage;
76 } //namespace container_detail {
78 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
81 //!@brief A variable-size array container with fixed capacity.
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.
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
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.
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.
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.
104 template <typename Value, std::size_t Capacity>
106 : public vector<Value, container_detail::static_storage_allocator<Value, Capacity> >
108 #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
109 typedef vector<Value, container_detail::static_storage_allocator<Value, Capacity> > base_t;
111 BOOST_COPYABLE_AND_MOVABLE(static_vector)
113 template<class U, std::size_t OtherCapacity>
114 friend class static_vector;
117 typedef container_detail::static_storage_allocator<Value, Capacity> allocator_type;
118 #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
121 //! @brief The type of elements stored in the container.
122 typedef typename base_t::value_type value_type;
123 //! @brief The unsigned integral type used by the container.
124 typedef typename base_t::size_type size_type;
125 //! @brief The pointers difference type.
126 typedef typename base_t::difference_type difference_type;
127 //! @brief The pointer type.
128 typedef typename base_t::pointer pointer;
129 //! @brief The const pointer type.
130 typedef typename base_t::const_pointer const_pointer;
131 //! @brief The value reference type.
132 typedef typename base_t::reference reference;
133 //! @brief The value const reference type.
134 typedef typename base_t::const_reference const_reference;
135 //! @brief The iterator type.
136 typedef typename base_t::iterator iterator;
137 //! @brief The const iterator type.
138 typedef typename base_t::const_iterator const_iterator;
139 //! @brief The reverse iterator type.
140 typedef typename base_t::reverse_iterator reverse_iterator;
141 //! @brief The const reverse iterator.
142 typedef typename base_t::const_reverse_iterator const_reverse_iterator;
144 //! @brief The capacity/max size of the container
145 static const size_type static_capacity = Capacity;
147 //! @brief Constructs an empty static_vector.
154 BOOST_CONTAINER_FORCEINLINE static_vector() BOOST_NOEXCEPT_OR_NOTHROW
158 //! @pre <tt>count <= capacity()</tt>
160 //! @brief Constructs a static_vector containing count value initialized values.
162 //! @param count The number of values which will be contained in the container.
165 //! If Value's value initialization throws.
169 BOOST_CONTAINER_FORCEINLINE explicit static_vector(size_type count)
173 //! @pre <tt>count <= capacity()</tt>
175 //! @brief Constructs a static_vector containing count default initialized values.
177 //! @param count The number of values which will be contained in the container.
180 //! If Value's default initialization throws.
186 //! Non-standard extension
187 BOOST_CONTAINER_FORCEINLINE static_vector(size_type count, default_init_t)
188 : base_t(count, default_init_t())
191 //! @pre <tt>count <= capacity()</tt>
193 //! @brief Constructs a static_vector containing count copies of value.
195 //! @param count The number of copies of a values that will be contained in the container.
196 //! @param value The value which will be used to copy construct values.
199 //! If Value's copy constructor throws.
203 BOOST_CONTAINER_FORCEINLINE static_vector(size_type count, value_type const& value)
204 : base_t(count, value)
208 //! @li <tt>distance(first, last) <= capacity()</tt>
209 //! @li Iterator must meet the \c ForwardTraversalIterator concept.
211 //! @brief Constructs a static_vector containing copy of a range <tt>[first, last)</tt>.
213 //! @param first The iterator to the first element in range.
214 //! @param last The iterator to the one after the last element in range.
217 //! If Value's constructor taking a dereferenced Iterator throws.
221 template <typename Iterator>
222 BOOST_CONTAINER_FORCEINLINE static_vector(Iterator first, Iterator last)
223 : base_t(first, last)
226 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
228 //! @li <tt>distance(il.begin(), il.end()) <= capacity()</tt>
230 //! @brief Constructs a static_vector containing copy of a range <tt>[il.begin(), il.end())</tt>.
232 //! @param il std::initializer_list with values to initialize vector.
235 //! If Value's constructor taking a dereferenced std::initializer_list throws.
239 BOOST_CONTAINER_FORCEINLINE static_vector(std::initializer_list<value_type> il)
244 //! @brief Constructs a copy of other static_vector.
246 //! @param other The static_vector which content will be copied to this one.
249 //! If Value's copy constructor throws.
253 BOOST_CONTAINER_FORCEINLINE static_vector(static_vector const& other)
257 BOOST_CONTAINER_FORCEINLINE static_vector(static_vector const& other, const allocator_type &)
261 BOOST_CONTAINER_FORCEINLINE static_vector(BOOST_RV_REF(static_vector) other, const allocator_type &)
262 BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible<value_type>::value)
263 : base_t(BOOST_MOVE_BASE(base_t, other))
266 BOOST_CONTAINER_FORCEINLINE explicit static_vector(const allocator_type &)
270 //! @pre <tt>other.size() <= capacity()</tt>.
272 //! @brief Constructs a copy of other static_vector.
274 //! @param other The static_vector which content will be copied to this one.
277 //! If Value's copy constructor throws.
281 template <std::size_t C>
282 BOOST_CONTAINER_FORCEINLINE static_vector(static_vector<value_type, C> const& other)
286 //! @brief Move constructor. Moves Values stored in the other static_vector to this one.
288 //! @param other The static_vector which content will be moved to this one.
291 //! @li If \c has_nothrow_move<Value>::value is \c true and Value's move constructor throws.
292 //! @li If \c has_nothrow_move<Value>::value is \c false and Value's copy constructor throws.
296 BOOST_CONTAINER_FORCEINLINE static_vector(BOOST_RV_REF(static_vector) other)
297 BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible<value_type>::value)
298 : base_t(BOOST_MOVE_BASE(base_t, other))
301 //! @pre <tt>other.size() <= capacity()</tt>
303 //! @brief Move constructor. Moves Values stored in the other static_vector to this one.
305 //! @param other The static_vector which content will be moved to this one.
308 //! @li If \c has_nothrow_move<Value>::value is \c true and Value's move constructor throws.
309 //! @li If \c has_nothrow_move<Value>::value is \c false and Value's copy constructor throws.
313 template <std::size_t C>
314 BOOST_CONTAINER_FORCEINLINE static_vector(BOOST_RV_REF_BEG static_vector<value_type, C> BOOST_RV_REF_END other)
315 : base_t(BOOST_MOVE_BASE(typename static_vector<value_type BOOST_MOVE_I C>::base_t, other))
318 //! @brief Copy assigns Values stored in the other static_vector to this one.
320 //! @param other The static_vector which content will be copied to this one.
323 //! If Value's copy constructor or copy assignment throws.
327 BOOST_CONTAINER_FORCEINLINE static_vector & operator=(BOOST_COPY_ASSIGN_REF(static_vector) other)
329 return static_cast<static_vector&>(base_t::operator=(static_cast<base_t const&>(other)));
332 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
333 //! @brief Copy assigns Values stored in std::initializer_list to *this.
335 //! @param il The std::initializer_list which content will be copied to this one.
338 //! If Value's copy constructor or copy assignment throws.
342 BOOST_CONTAINER_FORCEINLINE static_vector & operator=(std::initializer_list<value_type> il)
343 { return static_cast<static_vector&>(base_t::operator=(il)); }
346 //! @pre <tt>other.size() <= capacity()</tt>
348 //! @brief Copy assigns Values stored in the other static_vector to this one.
350 //! @param other The static_vector which content will be copied to this one.
353 //! If Value's copy constructor or copy assignment throws.
357 template <std::size_t C>
358 BOOST_CONTAINER_FORCEINLINE static_vector & operator=(static_vector<value_type, C> const& other)
360 return static_cast<static_vector&>(base_t::operator=
361 (static_cast<typename static_vector<value_type, C>::base_t const&>(other)));
364 //! @brief Move assignment. Moves Values stored in the other static_vector to this one.
366 //! @param other The static_vector which content will be moved to this one.
369 //! @li If \c has_nothrow_move<Value>::value is \c true and Value's move constructor or move assignment throws.
370 //! @li If \c has_nothrow_move<Value>::value is \c false and Value's copy constructor or copy assignment throws.
374 BOOST_CONTAINER_FORCEINLINE static_vector & operator=(BOOST_RV_REF(static_vector) other)
376 return static_cast<static_vector&>(base_t::operator=(BOOST_MOVE_BASE(base_t, other)));
379 //! @pre <tt>other.size() <= capacity()</tt>
381 //! @brief Move assignment. Moves Values stored in the other static_vector to this one.
383 //! @param other The static_vector which content will be moved to this one.
386 //! @li If \c has_nothrow_move<Value>::value is \c true and Value's move constructor or move assignment throws.
387 //! @li If \c has_nothrow_move<Value>::value is \c false and Value's copy constructor or copy assignment throws.
391 template <std::size_t C>
392 BOOST_CONTAINER_FORCEINLINE static_vector & operator=(BOOST_RV_REF_BEG static_vector<value_type, C> BOOST_RV_REF_END other)
394 return static_cast<static_vector&>(base_t::operator=
395 (BOOST_MOVE_BASE(typename static_vector<value_type BOOST_MOVE_I C>::base_t, other)));
398 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
400 //! @brief Destructor. Destroys Values stored in this container.
409 //! @brief Swaps contents of the other static_vector and this one.
411 //! @param other The static_vector which content will be swapped with this one's content.
414 //! @li If \c has_nothrow_move<Value>::value is \c true and Value's move constructor or move assignment throws,
415 //! @li If \c has_nothrow_move<Value>::value is \c false and Value's copy constructor or copy assignment throws,
419 void swap(static_vector & other);
421 //! @pre <tt>other.size() <= capacity() && size() <= other.capacity()</tt>
423 //! @brief Swaps contents of the other static_vector and this one.
425 //! @param other The static_vector which content will be swapped with this one's content.
428 //! @li If \c has_nothrow_move<Value>::value is \c true and Value's move constructor or move assignment throws,
429 //! @li If \c has_nothrow_move<Value>::value is \c false and Value's copy constructor or copy assignment throws,
433 template <std::size_t C>
434 void swap(static_vector<value_type, C> & other);
436 //! @pre <tt>count <= capacity()</tt>
438 //! @brief Inserts or erases elements at the end such that
439 //! the size becomes count. New elements are value initialized.
441 //! @param count The number of elements which will be stored in the container.
444 //! If Value's value initialization throws.
448 void resize(size_type count);
450 //! @pre <tt>count <= capacity()</tt>
452 //! @brief Inserts or erases elements at the end such that
453 //! the size becomes count. New elements are default initialized.
455 //! @param count The number of elements which will be stored in the container.
458 //! If Value's default initialization throws.
464 //! Non-standard extension
465 void resize(size_type count, default_init_t);
467 //! @pre <tt>count <= capacity()</tt>
469 //! @brief Inserts or erases elements at the end such that
470 //! the size becomes count. New elements are copy constructed from value.
472 //! @param count The number of elements which will be stored in the container.
473 //! @param value The value used to copy construct the new element.
476 //! If Value's copy constructor throws.
480 void resize(size_type count, value_type const& value);
482 //! @pre <tt>count <= capacity()</tt>
484 //! @brief This call has no effect because the Capacity of this container is constant.
486 //! @param count The number of elements which the container should be able to contain.
493 void reserve(size_type count) BOOST_NOEXCEPT_OR_NOTHROW;
495 //! @pre <tt>size() < capacity()</tt>
497 //! @brief Adds a copy of value at the end.
499 //! @param value The value used to copy construct the new element.
502 //! If Value's copy constructor throws.
506 void push_back(value_type const& value);
508 //! @pre <tt>size() < capacity()</tt>
510 //! @brief Moves value to the end.
512 //! @param value The value to move construct the new element.
515 //! If Value's move constructor throws.
519 void push_back(BOOST_RV_REF(value_type) value);
521 //! @pre <tt>!empty()</tt>
523 //! @brief Destroys last value and decreases the size.
526 //! Nothing by default.
533 //! @li \c p must be a valid iterator of \c *this in range <tt>[begin(), end()]</tt>.
534 //! @li <tt>size() < capacity()</tt>
536 //! @brief Inserts a copy of element at p.
538 //! @param p The position at which the new value will be inserted.
539 //! @param value The value used to copy construct the new element.
542 //! @li If Value's copy constructor or copy assignment throws
543 //! @li If Value's move constructor or move assignment throws.
546 //! Constant or linear.
547 iterator insert(const_iterator p, value_type const& value);
550 //! @li \c p must be a valid iterator of \c *this in range <tt>[begin(), end()]</tt>.
551 //! @li <tt>size() < capacity()</tt>
553 //! @brief Inserts a move-constructed element at p.
555 //! @param p The position at which the new value will be inserted.
556 //! @param value The value used to move construct the new element.
559 //! If Value's move constructor or move assignment throws.
562 //! Constant or linear.
563 iterator insert(const_iterator p, BOOST_RV_REF(value_type) value);
566 //! @li \c p must be a valid iterator of \c *this in range <tt>[begin(), end()]</tt>.
567 //! @li <tt>size() + count <= capacity()</tt>
569 //! @brief Inserts a count copies of value at p.
571 //! @param p The position at which new elements will be inserted.
572 //! @param count The number of new elements which will be inserted.
573 //! @param value The value used to copy construct new elements.
576 //! @li If Value's copy constructor or copy assignment throws.
577 //! @li If Value's move constructor or move assignment throws.
581 iterator insert(const_iterator p, size_type count, value_type const& value);
584 //! @li \c p must be a valid iterator of \c *this in range <tt>[begin(), end()]</tt>.
585 //! @li <tt>distance(first, last) <= capacity()</tt>
586 //! @li \c Iterator must meet the \c ForwardTraversalIterator concept.
588 //! @brief Inserts a copy of a range <tt>[first, last)</tt> at p.
590 //! @param p The position at which new elements will be inserted.
591 //! @param first The iterator to the first element of a range used to construct new elements.
592 //! @param last The iterator to the one after the last element of a range used to construct new elements.
595 //! @li If Value's constructor and assignment taking a dereferenced \c Iterator.
596 //! @li If Value's move constructor or move assignment throws.
600 template <typename Iterator>
601 iterator insert(const_iterator p, Iterator first, Iterator last);
604 //! @li \c p must be a valid iterator of \c *this in range <tt>[begin(), end()]</tt>.
605 //! @li <tt>distance(il.begin(), il.end()) <= capacity()</tt>
607 //! @brief Inserts a copy of a range <tt>[il.begin(), il.end())</tt> at p.
609 //! @param p The position at which new elements will be inserted.
610 //! @param il The std::initializer_list which contains elements that will be inserted.
613 //! @li If Value's constructor and assignment taking a dereferenced std::initializer_list iterator.
617 iterator insert(const_iterator p, std::initializer_list<value_type> il);
619 //! @pre \c p must be a valid iterator of \c *this in range <tt>[begin(), end())</tt>
621 //! @brief Erases Value from p.
623 //! @param p The position of the element which will be erased from the container.
626 //! If Value's move assignment throws.
630 iterator erase(const_iterator p);
633 //! @li \c first and \c last must define a valid range
634 //! @li iterators must be in range <tt>[begin(), end()]</tt>
636 //! @brief Erases Values from a range <tt>[first, last)</tt>.
638 //! @param first The position of the first element of a range which will be erased from the container.
639 //! @param last The position of the one after the last element of a range which will be erased from the container.
642 //! If Value's move assignment throws.
646 iterator erase(const_iterator first, const_iterator last);
648 //! @pre <tt>distance(first, last) <= capacity()</tt>
650 //! @brief Assigns a range <tt>[first, last)</tt> of Values to this container.
652 //! @param first The iterator to the first element of a range used to construct new content of this container.
653 //! @param last The iterator to the one after the last element of a range used to construct new content of this container.
656 //! If Value's copy constructor or copy assignment throws,
660 template <typename Iterator>
661 void assign(Iterator first, Iterator last);
663 //! @pre <tt>distance(il.begin(), il.end()) <= capacity()</tt>
665 //! @brief Assigns a range <tt>[il.begin(), il.end())</tt> of Values to this container.
667 //! @param il std::initializer_list with values used to construct new content of this container.
670 //! If Value's copy constructor or copy assignment throws,
674 void assign(std::initializer_list<value_type> il);
676 //! @pre <tt>count <= capacity()</tt>
678 //! @brief Assigns a count copies of value to this container.
680 //! @param count The new number of elements which will be container in the container.
681 //! @param value The value which will be used to copy construct the new content.
684 //! If Value's copy constructor or copy assignment throws.
688 void assign(size_type count, value_type const& value);
690 //! @pre <tt>size() < capacity()</tt>
692 //! @brief Inserts a Value constructed with
693 //! \c std::forward<Args>(args)... in the end of the container.
695 //! @return A reference to the created object.
697 //! @param args The arguments of the constructor of the new element which will be created at the end of the container.
700 //! If in-place constructor throws or Value's move constructor throws.
704 template<class ...Args>
705 reference emplace_back(Args &&...args);
708 //! @li \c p must be a valid iterator of \c *this in range <tt>[begin(), end()]</tt>
709 //! @li <tt>size() < capacity()</tt>
711 //! @brief Inserts a Value constructed with
712 //! \c std::forward<Args>(args)... before p
714 //! @param p The position at which new elements will be inserted.
715 //! @param args The arguments of the constructor of the new element.
718 //! If in-place constructor throws or if Value's move constructor or move assignment throws.
721 //! Constant or linear.
722 template<class ...Args>
723 iterator emplace(const_iterator p, Args &&...args);
725 //! @brief Removes all elements from the container.
732 void clear() BOOST_NOEXCEPT_OR_NOTHROW;
734 //! @pre <tt>i < size()</tt>
736 //! @brief Returns reference to the i-th element.
738 //! @param i The element's index.
740 //! @return reference to the i-th element
741 //! from the beginning of the container.
744 //! \c std::out_of_range exception by default.
748 reference at(size_type i);
750 //! @pre <tt>i < size()</tt>
752 //! @brief Returns const reference to the i-th element.
754 //! @param i The element's index.
756 //! @return const reference to the i-th element
757 //! from the beginning of the container.
760 //! \c std::out_of_range exception by default.
764 const_reference at(size_type i) const;
766 //! @pre <tt>i < size()</tt>
768 //! @brief Returns reference to the i-th element.
770 //! @param i The element's index.
772 //! @return reference to the i-th element
773 //! from the beginning of the container.
776 //! Nothing by default.
780 reference operator[](size_type i);
782 //! @pre <tt>i < size()</tt>
784 //! @brief Returns const reference to the i-th element.
786 //! @param i The element's index.
788 //! @return const reference to the i-th element
789 //! from the beginning of the container.
792 //! Nothing by default.
796 const_reference operator[](size_type i) const;
798 //! @pre <tt>i =< size()</tt>
800 //! @brief Returns a iterator to the i-th element.
802 //! @param i The element's index.
804 //! @return a iterator to the i-th element.
807 //! Nothing by default.
811 iterator nth(size_type i);
813 //! @pre <tt>i =< size()</tt>
815 //! @brief Returns a const_iterator to the i-th element.
817 //! @param i The element's index.
819 //! @return a const_iterator to the i-th element.
822 //! Nothing by default.
826 const_iterator nth(size_type i) const;
828 //! @pre <tt>begin() <= p <= end()</tt>
830 //! @brief Returns the index of the element pointed by p.
832 //! @param p An iterator to the element.
834 //! @return The index of the element pointed by p.
837 //! Nothing by default.
841 size_type index_of(iterator p);
843 //! @pre <tt>begin() <= p <= end()</tt>
845 //! @brief Returns the index of the element pointed by p.
847 //! @param p A const_iterator to the element.
849 //! @return a const_iterator to the i-th element.
852 //! Nothing by default.
856 size_type index_of(const_iterator p) const;
860 //! @brief Returns reference to the first element.
862 //! @return reference to the first element
863 //! from the beginning of the container.
866 //! Nothing by default.
874 //! @brief Returns const reference to the first element.
876 //! @return const reference to the first element
877 //! from the beginning of the container.
880 //! Nothing by default.
884 const_reference front() const;
888 //! @brief Returns reference to the last element.
890 //! @return reference to the last element
891 //! from the beginning of the container.
894 //! Nothing by default.
902 //! @brief Returns const reference to the first element.
904 //! @return const reference to the last element
905 //! from the beginning of the container.
908 //! Nothing by default.
912 const_reference back() const;
914 //! @brief Pointer such that <tt>[data(), data() + size())</tt> is a valid range.
915 //! For a non-empty vector <tt>data() == &front()</tt>.
922 Value * data() BOOST_NOEXCEPT_OR_NOTHROW;
924 //! @brief Const pointer such that <tt>[data(), data() + size())</tt> is a valid range.
925 //! For a non-empty vector <tt>data() == &front()</tt>.
932 const Value * data() const BOOST_NOEXCEPT_OR_NOTHROW;
934 //! @brief Returns iterator to the first element.
936 //! @return iterator to the first element contained in the vector.
943 iterator begin() BOOST_NOEXCEPT_OR_NOTHROW;
945 //! @brief Returns const iterator to the first element.
947 //! @return const_iterator to the first element contained in the vector.
954 const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW;
956 //! @brief Returns const iterator to the first element.
958 //! @return const_iterator to the first element contained in the vector.
965 const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
967 //! @brief Returns iterator to the one after the last element.
969 //! @return iterator pointing to the one after the last element contained in the vector.
976 iterator end() BOOST_NOEXCEPT_OR_NOTHROW;
978 //! @brief Returns const iterator to the one after the last element.
980 //! @return const_iterator pointing to the one after the last element contained in the vector.
987 const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW;
989 //! @brief Returns const iterator to the one after the last element.
991 //! @return const_iterator pointing to the one after the last element contained in the vector.
998 const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW;
1000 //! @brief Returns reverse iterator to the first element of the reversed container.
1002 //! @return reverse_iterator pointing to the beginning
1003 //! of the reversed static_vector.
1010 reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW;
1012 //! @brief Returns const reverse iterator to the first element of the reversed container.
1014 //! @return const_reverse_iterator pointing to the beginning
1015 //! of the reversed static_vector.
1022 const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
1024 //! @brief Returns const reverse iterator to the first element of the reversed container.
1026 //! @return const_reverse_iterator pointing to the beginning
1027 //! of the reversed static_vector.
1034 const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
1036 //! @brief Returns reverse iterator to the one after the last element of the reversed container.
1038 //! @return reverse_iterator pointing to the one after the last element
1039 //! of the reversed static_vector.
1046 reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW;
1048 //! @brief Returns const reverse iterator to the one after the last element of the reversed container.
1050 //! @return const_reverse_iterator pointing to the one after the last element
1051 //! of the reversed static_vector.
1058 const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW;
1060 //! @brief Returns const reverse iterator to the one after the last element of the reversed container.
1062 //! @return const_reverse_iterator pointing to the one after the last element
1063 //! of the reversed static_vector.
1070 const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW;
1072 //! @brief Returns container's capacity.
1074 //! @return container's capacity.
1081 static size_type capacity() BOOST_NOEXCEPT_OR_NOTHROW;
1083 //! @brief Returns container's capacity.
1085 //! @return container's capacity.
1092 static size_type max_size() BOOST_NOEXCEPT_OR_NOTHROW;
1094 //! @brief Returns the number of stored elements.
1096 //! @return Number of elements contained in the container.
1103 size_type size() const BOOST_NOEXCEPT_OR_NOTHROW;
1105 //! @brief Queries if the container contains elements.
1107 //! @return true if the number of elements contained in the
1108 //! container is equal to 0.
1115 bool empty() const BOOST_NOEXCEPT_OR_NOTHROW;
1118 BOOST_CONTAINER_FORCEINLINE friend void swap(static_vector &x, static_vector &y)
1123 #endif // BOOST_CONTAINER_DOXYGEN_INVOKED
1127 #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
1129 //! @brief Checks if contents of two static_vectors are equal.
1131 //! @ingroup static_vector_non_member
1133 //! @param x The first static_vector.
1134 //! @param y The second static_vector.
1136 //! @return \c true if containers have the same size and elements in both containers are equal.
1140 template<typename V, std::size_t C1, std::size_t C2>
1141 bool operator== (static_vector<V, C1> const& x, static_vector<V, C2> const& y);
1143 //! @brief Checks if contents of two static_vectors are not equal.
1145 //! @ingroup static_vector_non_member
1147 //! @param x The first static_vector.
1148 //! @param y The second static_vector.
1150 //! @return \c true if containers have different size or elements in both containers are not equal.
1154 template<typename V, std::size_t C1, std::size_t C2>
1155 bool operator!= (static_vector<V, C1> const& x, static_vector<V, C2> const& y);
1157 //! @brief Lexicographically compares static_vectors.
1159 //! @ingroup static_vector_non_member
1161 //! @param x The first static_vector.
1162 //! @param y The second static_vector.
1164 //! @return \c true if x compares lexicographically less than y.
1168 template<typename V, std::size_t C1, std::size_t C2>
1169 bool operator< (static_vector<V, C1> const& x, static_vector<V, C2> const& y);
1171 //! @brief Lexicographically compares static_vectors.
1173 //! @ingroup static_vector_non_member
1175 //! @param x The first static_vector.
1176 //! @param y The second static_vector.
1178 //! @return \c true if y compares lexicographically less than x.
1182 template<typename V, std::size_t C1, std::size_t C2>
1183 bool operator> (static_vector<V, C1> const& x, static_vector<V, C2> const& y);
1185 //! @brief Lexicographically compares static_vectors.
1187 //! @ingroup static_vector_non_member
1189 //! @param x The first static_vector.
1190 //! @param y The second static_vector.
1192 //! @return \c true if y don't compare lexicographically less than x.
1196 template<typename V, std::size_t C1, std::size_t C2>
1197 bool operator<= (static_vector<V, C1> const& x, static_vector<V, C2> const& y);
1199 //! @brief Lexicographically compares static_vectors.
1201 //! @ingroup static_vector_non_member
1203 //! @param x The first static_vector.
1204 //! @param y The second static_vector.
1206 //! @return \c true if x don't compare lexicographically less than y.
1210 template<typename V, std::size_t C1, std::size_t C2>
1211 bool operator>= (static_vector<V, C1> const& x, static_vector<V, C2> const& y);
1213 //! @brief Swaps contents of two static_vectors.
1215 //! This function calls static_vector::swap().
1217 //! @ingroup static_vector_non_member
1219 //! @param x The first static_vector.
1220 //! @param y The second static_vector.
1224 template<typename V, std::size_t C1, std::size_t C2>
1225 inline void swap(static_vector<V, C1> & x, static_vector<V, C2> & y);
1229 template<typename V, std::size_t C1, std::size_t C2>
1230 inline void swap(static_vector<V, C1> & x, static_vector<V, C2> & y
1231 , typename container_detail::enable_if_c< C1 != C2>::type * = 0)
1236 #endif // BOOST_CONTAINER_DOXYGEN_INVOKED
1238 }} // namespace boost::container
1240 #include <boost/container/detail/config_end.hpp>
1242 #endif // BOOST_CONTAINER_STATIC_VECTOR_HPP