Debian Codegraph @

headers/vector

raw
1 /* Copyright (C) 2015 Povilas Kanapickas <[email protected]>
2
3 This file is part of cppreference-doc
4
5 This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
6 Unported License. To view a copy of this license, visit
7 http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
8 Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
9
10 Permission is granted to copy, distribute and/or modify this document
11 under the terms of the GNU Free Documentation License, Version 1.3 or
12 any later version published by the Free Software Foundation; with no
13 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
14 */
15
16 #ifndef CPPREFERENCE_VECTOR_H
17 #define CPPREFERENCE_VECTOR_H
18
19 #if CPPREFERENCE_STDVER >= 2011
20 #include <initializer_list>
21 #endif`
22
23 namespace std {
24
25 template<class T, class Allocator = allocator<T>>
26 class vector {
27 public:
28 typedef T value_type;
29 typedef Allocator allocator_type;
30 typedef size_t size_type; // actual type unspecified
31 typedef ptrdiff_t difference_type; // actual type not specified
32 #if CPPREFERENCE_SIMPLIFY_TYPEDEFS
33 typedef T& reference;
34 typedef const T& const_reference;
35 typedef T* pointer;
36 typedef const T* const_pointer;
37 #elif CPPREFERENCE_STDVER <2011
38 typedef typename Allocator::reference reference;
39 typedef typename Allocator::const_reference const_reference;
40 typedef typename Allocator::pointer pointer;
41 typedef typename Allocator::const_pointer const_pointer;
42 #else
43 typedef value_type& reference;
44 typedef const value_type& const_reference;
45 typedef typename std::allocator_traits<Allocator>::pointer pointer;
46 typedef typename std::allocator_traits<Allocator>::const_pointer const_pointer;
47 #endif
48 typedef T* iterator; // actual type is unspecified
49 typedef const T* const_iterator; // actual type is unspecified
50 typedef std::reverse_iterator<iterator> reverse_iterator;
51 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
52
53 // constructor
54 #if CPPREFERENCE_STDVER <2014
55 explicit vector(const Allocator& alloc = Allocator());
56 #else
57 vector();
58 explicit vector(const Allocator& alloc);
59 #endif
60
61 #if CPPREFERENCE_STDVER <2011
62 explicit vector(size_type count,
63 const T& value = T(),
64 const Allocator& alloc = Allocator());
65 #else
66 vector(size_type count,
67 const T& value,
68 const Allocator& alloc = Allocator());
69 #endif
70
71 #if CPPREFERENCE_STDVER <2014
72 explicit vector(size_type n);
73 #else
74 explicit vector(size_type n, const Allocator& alloc = Allocator());
75 #endif
76
77 template<class InputIt>
78 vector(InputIt first, InputIt last,
79 const Allocator& alloc = Allocator());
80
81 vector(const vector& other);
82 #if CPPREFERENCE_STDVER>= 2011
83 vector(const vector& other, const Allocator& alloc);
84 #endif
85
86 vector(vector&& other);
87 #if CPPREFERENCE_STDVER>= 2011
88 vector(vector&& other, const Allocator& alloc);
89
90 vector(std::initializer_list<T> init,
91 const Allocator& alloc = Allocator());
92 #endif
93
94 ~vector();
95
96 vector& operator=(const vector& other);
97 #if CPPREFERENCE_STDVER>= 2011
98 vector& operator=(vector&& other);
99 vector& operator=(initializer_list<T> ilist);
100 #endif
101
102 void assign(size_type count, const value_type& value);
103 template <class InputIt>
104 void assign(InputIt first, InputIt last);
105 #if CPPREFERENCE_STDVER>= 2011
106 void assign(std::initializer_list<T> ilist);
107 #endif
108
109 allocator_type get_allocator() const;
110
111 // element access
112 reference at(size_type n);
113 const_reference at(size_type n) const;
114 reference operator[](size_type n);
115 const_reference operator[](size_type n) const;
116
117 reference front();
118 const_reference front() const;
119 reference back();
120 const_reference back() const;
121 #if CPPREFERENCE_STDVER>= 2011
122 value_type* data();
123 const value_type* data() const;
124 #endif
125
126 // iterators
127 iterator begin();
128 const_iterator begin() const;
129 iterator end();
130 const_iterator end() const;
131
132 reverse_iterator rbegin();
133 const_reverse_iterator rbegin() const;
134 reverse_iterator rend();
135 const_reverse_iterator rend() const;
136
137 #if CPPREFERENCE_STDVER>= 2011
138 const_iterator cbegin() const;
139 const_iterator cend() const;
140 const_reverse_iterator crbegin() const;
141 const_reverse_iterator crend() const;
142 #endif
143
144 // capacity
145 bool empty() const;
146 size_type size() const;
147 size_type max_size() const;
148 void reserve(size_type n);
149 size_type capacity() const;
150
151 #if CPPREFERENCE_STDVER>= 2011
152 void shrink_to_fit();
153 #endif
154
155 // modifiers
156 void clear();
157
158 #if CPPREFERENCE_STDVER <2011
159 iterator insert(iterator pos, const T& value);
160 void insert(iterator pos, size_type count, const T& value);
161 template<class InputIt>
162 void insert(iterator pos, InputIt first, InputIt last);
163 #else
164 iterator insert(const_iterator pos, const T& value);
165 iterator insert(const_iterator pos, T&& value);
166 iterator insert(const_iterator pos, size_type count, const T& value);
167 template<class InputIt>
168 iterator insert(const_iterator pos, InputIt first, InputIt last);
169 iterator insert(const_iterator pos, std::initializer_list<T> ilist);
170 #endif
171
172 #if CPPREFERENCE_STDVER>= 2011
173 template<class... Args>
174 iterator emplace(const_iterator pos, Args&& ... args);
175 #endif
176
177 #if CPPREFERENCE_STDVER <2011
178 iterator erase(iterator pos);
179 iterator erase(iterator first, iterator last);
180 #else
181 iterator erase(const_iterator pos);
182 iterator erase(const_iterator first, const_iterator last);
183 #endif
184
185 void push_back(const T& value);
186 #if CPPREFERENCE_STDVER>= 2011
187 void push_back(T&& value);
188 #endif
189
190 #if CPPREFERENCE_STDVER>= 2011
191 template<class... Args>
192 void emplace_back(Args&& ... args);
193 #endif
194
195 void pop_back();
196
197 #if CPPREFERENCE_STDVER <2011
198 void resize(size_type count, T value = T());
199 #else
200 void resize(size_type count);
201 void resize(size_type count, const value_type& value);
202 #endif
203
204 void swap(vector& other);
205 };
206
207 template<class T, class Alloc>
208 bool operator==(const vector<T, Alloc>& lhs,
209 const vector<T, Alloc>& rhs);
210
211 template<class T, class Alloc>
212 bool operator!=(const vector<T, Alloc>& lhs,
213 const vector<T, Alloc>& rhs);
214
215 template<class T, class Alloc>
216 bool operator<(const vector<T, Alloc>& lhs,
217 const vector<T, Alloc>& rhs);
218
219 template<class T, class Alloc>
220 bool operator<=(const vector<T, Alloc>& lhs,
221 const vector<T, Alloc>& rhs);
222
223 template<class T, class Alloc>
224 bool operator>(const vector<T, Alloc>& lhs,
225 const vector<T, Alloc>& rhs);
226
227 template<class T, class Alloc>
228 bool operator>=(const vector<T, Alloc>& lhs,
229 const vector<T, Alloc>& rhs);
230
231 } // namespace std
232
233 #endif // CPPREFERENCE_VECTOR_H