From Jason Turner

[vector.overview]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmppdgs6tae/{from.md → to.md} +54 -44
tmp/tmppdgs6tae/{from.md → to.md} RENAMED
@@ -1,62 +1,60 @@
1
  #### Class template `vector` overview <a id="vector.overview">[[vector.overview]]</a>
2
 
3
- A `vector` is a sequence container that supports random access
4
- iterators. In addition, it supports (amortized) constant time insert and
5
- erase operations at the end; insert and erase in the middle take linear
6
- time. Storage management is handled automatically, though hints can be
7
- given to improve efficiency. The elements of a vector are stored
8
- contiguously, meaning that if `v` is a `vector<T, Allocator>` where `T`
9
- is some type other than `bool`, then it obeys the identity
10
- `&v[n] == &v[0] + n` for all `0 <= n < v.size()`.
11
 
12
  A `vector` satisfies all of the requirements of a container and of a
13
  reversible container (given in two tables in 
14
  [[container.requirements]]), of a sequence container, including most of
15
- the optional sequence container requirements ([[sequence.reqmts]]), and
16
- of an allocator-aware container (Table 
17
- [[tab:containers.allocatoraware]]). The exceptions are the `push_front`,
18
- `pop_front`, and `emplace_front` member functions, which are not
19
- provided. Descriptions are provided here only for operations on `vector`
20
- that are not described in one of these tables or for operations where
21
- there is additional semantic information.
 
22
 
23
  ``` cpp
24
  namespace std {
25
  template <class T, class Allocator = allocator<T>>
26
  class vector {
27
  public:
28
  // types:
29
- typedef value_type& reference;
30
- typedef const value_type& const_reference;
31
- typedef implementation-defined iterator; // see [container.requirements]
32
- typedef implementation-defined const_iterator; // see [container.requirements]
33
- typedef implementation-defined size_type; // see [container.requirements]
34
- typedef implementation-defined difference_type;// see [container.requirements]
35
- typedef T value_type;
36
- typedef Allocator allocator_type;
37
- typedef typename allocator_traits<Allocator>::pointer pointer;
38
- typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
39
- typedef std::reverse_iterator<iterator> reverse_iterator;
40
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
41
 
42
- // [vector.cons], construct/copy/destroy:
43
- vector() : vector(Allocator()) { }
44
- explicit vector(const Allocator&);
45
  explicit vector(size_type n, const Allocator& = Allocator());
46
  vector(size_type n, const T& value, const Allocator& = Allocator());
47
  template <class InputIterator>
48
- vector(InputIterator first, InputIterator last,
49
- const Allocator& = Allocator());
50
  vector(const vector& x);
51
- vector(vector&&);
52
  vector(const vector&, const Allocator&);
53
  vector(vector&&, const Allocator&);
54
  vector(initializer_list<T>, const Allocator& = Allocator());
55
  ~vector();
56
  vector& operator=(const vector& x);
57
- vector& operator=(vector&& x);
 
 
58
  vector& operator=(initializer_list<T>);
59
  template <class InputIterator>
60
  void assign(InputIterator first, InputIterator last);
61
  void assign(size_type n, const T& u);
62
  void assign(initializer_list<T>);
@@ -75,17 +73,17 @@ namespace std {
75
  const_iterator cbegin() const noexcept;
76
  const_iterator cend() const noexcept;
77
  const_reverse_iterator crbegin() const noexcept;
78
  const_reverse_iterator crend() const noexcept;
79
 
80
- // [vector.capacity], capacity:
 
81
  size_type size() const noexcept;
82
  size_type max_size() const noexcept;
 
83
  void resize(size_type sz);
84
  void resize(size_type sz, const T& c);
85
- size_type capacity() const noexcept;
86
- bool empty() const noexcept;
87
  void reserve(size_type n);
88
  void shrink_to_fit();
89
 
90
  // element access:
91
  reference operator[](size_type n);
@@ -99,30 +97,36 @@ namespace std {
99
 
100
  // [vector.data], data access
101
  T* data() noexcept;
102
  const T* data() const noexcept;
103
 
104
- // [vector.modifiers], modifiers:
105
- template <class... Args> void emplace_back(Args&&... args);
106
  void push_back(const T& x);
107
  void push_back(T&& x);
108
  void pop_back();
109
 
110
  template <class... Args> iterator emplace(const_iterator position, Args&&... args);
111
  iterator insert(const_iterator position, const T& x);
112
  iterator insert(const_iterator position, T&& x);
113
  iterator insert(const_iterator position, size_type n, const T& x);
114
  template <class InputIterator>
115
- iterator insert(const_iterator position,
116
- InputIterator first, InputIterator last);
117
  iterator insert(const_iterator position, initializer_list<T> il);
118
  iterator erase(const_iterator position);
119
  iterator erase(const_iterator first, const_iterator last);
120
- void swap(vector&);
 
 
121
  void clear() noexcept;
122
  };
123
 
 
 
 
 
 
124
  template <class T, class Allocator>
125
  bool operator==(const vector<T, Allocator>& x, const vector<T, Allocator>& y);
126
  template <class T, class Allocator>
127
  bool operator< (const vector<T, Allocator>& x, const vector<T, Allocator>& y);
128
  template <class T, class Allocator>
@@ -132,11 +136,17 @@ namespace std {
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
 
137
- // [vector.special], specialized algorithms:
138
  template <class T, class Allocator>
139
- void swap(vector<T,Allocator>& x, vector<T,Allocator>& y);
 
140
  }
141
  ```
142
 
 
 
 
 
 
 
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&;
31
+ using const_reference = const value_type&;
32
+ using size_type = implementation-defined; // see [container.requirements]
33
+ using difference_type = implementation-defined; // see [container.requirements]
34
+ using iterator = implementation-defined // type of vector::iterator; // see [container.requirements]
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>);
 
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);
 
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>
 
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
+