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