From Jason Turner

[vector.overview]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp_oym9jm4/{from.md → to.md} +85 -95
tmp/tmp_oym9jm4/{from.md → to.md} RENAMED
@@ -1,30 +1,33 @@
1
- #### Class template `vector` overview <a id="vector.overview">[[vector.overview]]</a>
2
 
3
  A `vector` is a sequence container that supports (amortized) constant
4
  time insert and erase operations at the end; insert and erase in the
5
  middle take linear time. Storage management is handled automatically,
6
  though hints can be given to improve efficiency.
7
 
8
- A `vector` satisfies all of the requirements of a container and of a
9
  reversible container (given in two tables in 
10
  [[container.requirements]]), of a sequence container, including most of
11
- the optional sequence container requirements ([[sequence.reqmts]]), of
12
- an allocator-aware container (Table  [[tab:containers.allocatoraware]]),
13
- and, for an element type other than `bool`, of a contiguous container (
14
- [[container.requirements.general]]). The exceptions are the
15
- `push_front`, `pop_front`, and `emplace_front` member functions, which
16
- are not provided. Descriptions are provided here only for operations on
17
- `vector` that are not described in one of these tables or for operations
18
- where there is additional semantic information.
 
 
 
19
 
20
  ``` cpp
21
  namespace std {
22
  template<class T, class Allocator = allocator<T>>
23
  class vector {
24
  public:
25
- // types:
26
  using value_type = T;
27
  using allocator_type = Allocator;
28
  using pointer = typename allocator_traits<Allocator>::pointer;
29
  using const_pointer = typename allocator_traits<Allocator>::const_pointer;
30
  using reference = value_type&;
@@ -35,118 +38,105 @@ namespace std {
35
  using const_iterator = implementation-defined // type of vector::const_iterator; // see [container.requirements]
36
  using reverse_iterator = std::reverse_iterator<iterator>;
37
  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
38
 
39
  // [vector.cons], construct/copy/destroy
40
- vector() noexcept(noexcept(Allocator())) : vector(Allocator()) { }
41
- explicit vector(const Allocator&) noexcept;
42
- explicit vector(size_type n, const Allocator& = Allocator());
43
- vector(size_type n, const T& value, const Allocator& = Allocator());
44
  template<class InputIterator>
45
- vector(InputIterator first, InputIterator last, const Allocator& = Allocator());
46
- vector(const vector& x);
47
- vector(vector&&) noexcept;
48
- vector(const vector&, const Allocator&);
49
- vector(vector&&, const Allocator&);
50
- vector(initializer_list<T>, const Allocator& = Allocator());
51
- ~vector();
52
- vector& operator=(const vector& x);
53
- vector& operator=(vector&& x)
54
  noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
55
  allocator_traits<Allocator>::is_always_equal::value);
56
- vector& operator=(initializer_list<T>);
57
  template<class InputIterator>
58
- void assign(InputIterator first, InputIterator last);
59
- void assign(size_type n, const T& u);
60
- void assign(initializer_list<T>);
61
- allocator_type get_allocator() const noexcept;
62
 
63
- // iterators:
64
- iterator begin() noexcept;
65
- const_iterator begin() const noexcept;
66
- iterator end() noexcept;
67
- const_iterator end() const noexcept;
68
- reverse_iterator rbegin() noexcept;
69
- const_reverse_iterator rbegin() const noexcept;
70
- reverse_iterator rend() noexcept;
71
- const_reverse_iterator rend() const noexcept;
72
 
73
- const_iterator cbegin() const noexcept;
74
- const_iterator cend() const noexcept;
75
- const_reverse_iterator crbegin() const noexcept;
76
- const_reverse_iterator crend() const noexcept;
77
 
78
  // [vector.capacity], capacity
79
- bool empty() const noexcept;
80
- size_type size() const noexcept;
81
- size_type max_size() const noexcept;
82
- size_type capacity() const noexcept;
83
- void resize(size_type sz);
84
- void resize(size_type sz, const T& c);
85
- void reserve(size_type n);
86
- void shrink_to_fit();
87
 
88
- // element access:
89
- reference operator[](size_type n);
90
- const_reference operator[](size_type n) const;
91
- const_reference at(size_type n) const;
92
- reference at(size_type n);
93
- reference front();
94
- const_reference front() const;
95
- reference back();
96
- const_reference back() const;
97
 
98
  // [vector.data], data access
99
- T* data() noexcept;
100
- const T* data() const noexcept;
101
 
102
  // [vector.modifiers], modifiers
103
- template <class... Args> reference emplace_back(Args&&... args);
104
- void push_back(const T& x);
105
- void push_back(T&& x);
106
- void pop_back();
107
 
108
- template <class... Args> iterator emplace(const_iterator position, Args&&... args);
109
- iterator insert(const_iterator position, const T& x);
110
- iterator insert(const_iterator position, T&& x);
111
- iterator insert(const_iterator position, size_type n, const T& x);
112
  template<class InputIterator>
113
- iterator insert(const_iterator position, InputIterator first, InputIterator last);
114
- iterator insert(const_iterator position, initializer_list<T> il);
115
- iterator erase(const_iterator position);
116
- iterator erase(const_iterator first, const_iterator last);
117
- void swap(vector&)
 
118
  noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
119
  allocator_traits<Allocator>::is_always_equal::value);
120
- void clear() noexcept;
121
  };
122
 
123
- template<class InputIterator,
124
- class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
125
  vector(InputIterator, InputIterator, Allocator = Allocator())
126
- -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>;
127
 
 
128
  template<class T, class Allocator>
129
- bool operator==(const vector<T, Allocator>& x, const vector<T, Allocator>& y);
130
- template <class T, class Allocator>
131
- bool operator< (const vector<T, Allocator>& x, const vector<T, Allocator>& y);
132
- template <class T, class Allocator>
133
- bool operator!=(const vector<T, Allocator>& x, const vector<T, Allocator>& y);
134
- template <class T, class Allocator>
135
- bool operator> (const vector<T, Allocator>& x, const vector<T, Allocator>& y);
136
- template <class T, class Allocator>
137
- bool operator>=(const vector<T, Allocator>& x, const vector<T, Allocator>& y);
138
- template <class T, class Allocator>
139
- bool operator<=(const vector<T, Allocator>& x, const vector<T, Allocator>& y);
140
-
141
- // [vector.special], specialized algorithms
142
- template <class T, class Allocator>
143
- void swap(vector<T, Allocator>& x, vector<T, Allocator>& y)
144
  noexcept(noexcept(x.swap(y)));
145
  }
146
  ```
147
 
148
  An incomplete type `T` may be used when instantiating `vector` if the
149
- allocator satisfies the allocator completeness requirements (
150
- [[allocator.requirements.completeness]]). `T` shall be complete before
151
  any member of the resulting specialization of `vector` is referenced.
152
 
 
1
+ #### Overview <a id="vector.overview">[[vector.overview]]</a>
2
 
3
  A `vector` is a sequence container that supports (amortized) constant
4
  time insert and erase operations at the end; insert and erase in the
5
  middle take linear time. Storage management is handled automatically,
6
  though hints can be given to improve efficiency.
7
 
8
+ A `vector` meets all of the requirements of a container and of a
9
  reversible container (given in two tables in 
10
  [[container.requirements]]), of a sequence container, including most of
11
+ the optional sequence container requirements [[sequence.reqmts]], of an
12
+ allocator-aware container ([[container.alloc.req]]), and, for an
13
+ element type other than `bool`, of a contiguous container
14
+ [[container.requirements.general]]. The exceptions are the `push_front`,
15
+ `pop_front`, and `emplace_front` member functions, which are not
16
+ provided. Descriptions are provided here only for operations on `vector`
17
+ that are not described in one of these tables or for operations where
18
+ there is additional semantic information.
19
+
20
+ The types `iterator` and `const_iterator` meet the constexpr iterator
21
+ requirements [[iterator.requirements.general]].
22
 
23
  ``` cpp
24
  namespace std {
25
  template<class T, class Allocator = allocator<T>>
26
  class vector {
27
  public:
28
+ // types
29
  using value_type = T;
30
  using allocator_type = Allocator;
31
  using pointer = typename allocator_traits<Allocator>::pointer;
32
  using const_pointer = typename allocator_traits<Allocator>::const_pointer;
33
  using reference = value_type&;
 
38
  using const_iterator = implementation-defined // type of vector::const_iterator; // see [container.requirements]
39
  using reverse_iterator = std::reverse_iterator<iterator>;
40
  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
41
 
42
  // [vector.cons], construct/copy/destroy
43
+ constexpr vector() noexcept(noexcept(Allocator())) : vector(Allocator()) { }
44
+ constexpr explicit vector(const Allocator&) noexcept;
45
+ constexpr explicit vector(size_type n, const Allocator& = Allocator());
46
+ constexpr vector(size_type n, const T& value, const Allocator& = Allocator());
47
  template<class InputIterator>
48
+ constexpr vector(InputIterator first, InputIterator last, const Allocator& = Allocator());
49
+ constexpr vector(const vector& x);
50
+ constexpr vector(vector&&) noexcept;
51
+ constexpr vector(const vector&, const Allocator&);
52
+ constexpr vector(vector&&, const Allocator&);
53
+ constexpr vector(initializer_list<T>, const Allocator& = Allocator());
54
+ constexpr ~vector();
55
+ constexpr vector& operator=(const vector& x);
56
+ constexpr vector& operator=(vector&& x)
57
  noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
58
  allocator_traits<Allocator>::is_always_equal::value);
59
+ constexpr vector& operator=(initializer_list<T>);
60
  template<class InputIterator>
61
+ constexpr void assign(InputIterator first, InputIterator last);
62
+ constexpr void assign(size_type n, const T& u);
63
+ constexpr void assign(initializer_list<T>);
64
+ constexpr allocator_type get_allocator() const noexcept;
65
 
66
+ // iterators
67
+ constexpr iterator begin() noexcept;
68
+ constexpr const_iterator begin() const noexcept;
69
+ constexpr iterator end() noexcept;
70
+ constexpr const_iterator end() const noexcept;
71
+ constexpr reverse_iterator rbegin() noexcept;
72
+ constexpr const_reverse_iterator rbegin() const noexcept;
73
+ constexpr reverse_iterator rend() noexcept;
74
+ constexpr const_reverse_iterator rend() const noexcept;
75
 
76
+ constexpr const_iterator cbegin() const noexcept;
77
+ constexpr const_iterator cend() const noexcept;
78
+ constexpr const_reverse_iterator crbegin() const noexcept;
79
+ constexpr const_reverse_iterator crend() const noexcept;
80
 
81
  // [vector.capacity], capacity
82
+ [[nodiscard]] constexpr bool empty() const noexcept;
83
+ constexpr size_type size() const noexcept;
84
+ constexpr size_type max_size() const noexcept;
85
+ constexpr size_type capacity() const noexcept;
86
+ constexpr void resize(size_type sz);
87
+ constexpr void resize(size_type sz, const T& c);
88
+ constexpr void reserve(size_type n);
89
+ constexpr void shrink_to_fit();
90
 
91
+ // element access
92
+ constexpr reference operator[](size_type n);
93
+ constexpr const_reference operator[](size_type n) const;
94
+ constexpr const_reference at(size_type n) const;
95
+ constexpr reference at(size_type n);
96
+ constexpr reference front();
97
+ constexpr const_reference front() const;
98
+ constexpr reference back();
99
+ constexpr const_reference back() const;
100
 
101
  // [vector.data], data access
102
+ constexpr T* data() noexcept;
103
+ constexpr const T* data() const noexcept;
104
 
105
  // [vector.modifiers], modifiers
106
+ template<class... Args> constexpr reference emplace_back(Args&&... args);
107
+ constexpr void push_back(const T& x);
108
+ constexpr void push_back(T&& x);
109
+ constexpr void pop_back();
110
 
111
+ template<class... Args> constexpr iterator emplace(const_iterator position, Args&&... args);
112
+ constexpr iterator insert(const_iterator position, const T& x);
113
+ constexpr iterator insert(const_iterator position, T&& x);
114
+ constexpr iterator insert(const_iterator position, size_type n, const T& x);
115
  template<class InputIterator>
116
+ constexpr iterator insert(const_iterator position,
117
+ InputIterator first, InputIterator last);
118
+ constexpr iterator insert(const_iterator position, initializer_list<T> il);
119
+ constexpr iterator erase(const_iterator position);
120
+ constexpr iterator erase(const_iterator first, const_iterator last);
121
+ constexpr void swap(vector&)
122
  noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
123
  allocator_traits<Allocator>::is_always_equal::value);
124
+ constexpr void clear() noexcept;
125
  };
126
 
127
+ template<class InputIterator, class Allocator = allocator<iter-value-type<InputIterator>>>
 
128
  vector(InputIterator, InputIterator, Allocator = Allocator())
129
+ -> vector<iter-value-type<InputIterator>, Allocator>;
130
 
131
+ // swap
132
  template<class T, class Allocator>
133
+ constexpr void swap(vector<T, Allocator>& x, vector<T, Allocator>& y)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  noexcept(noexcept(x.swap(y)));
135
  }
136
  ```
137
 
138
  An incomplete type `T` may be used when instantiating `vector` if the
139
+ allocator meets the allocator completeness requirements
140
+ [[allocator.requirements.completeness]]. `T` shall be complete before
141
  any member of the resulting specialization of `vector` is referenced.
142