From Jason Turner

[vector.bool]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpgq1toy88/{from.md → to.md} +21 -21
tmp/tmpgq1toy88/{from.md → to.md} RENAMED
@@ -3,24 +3,25 @@
3
  To optimize space allocation, a specialization of vector for `bool`
4
  elements is provided:
5
 
6
  ``` cpp
7
  namespace std {
8
- template <class Allocator> class vector<bool, Allocator> {
 
9
  public:
10
  // types:
11
- typedef bool const_reference;
12
- typedef implementation-defined iterator; // see [container.requirements]
13
- typedef implementation-defined const_iterator; // see [container.requirements]
14
- typedef implementation-defined size_type; // see [container.requirements]
15
- typedef implementation-defined difference_type;// see [container.requirements]
16
- typedef bool value_type;
17
- typedef Allocator allocator_type;
18
- typedef implementation-defined pointer;
19
- typedef implementation-defined const_pointer;
20
- typedef std::reverse_iterator<iterator> reverse_iterator;
21
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
22
 
23
  // bit reference:
24
  class reference {
25
  friend class vector;
26
  reference() noexcept;
@@ -70,15 +71,15 @@ namespace std {
70
  const_iterator cend() const noexcept;
71
  const_reverse_iterator crbegin() const noexcept;
72
  const_reverse_iterator crend() const noexcept;
73
 
74
  // capacity:
 
75
  size_type size() const noexcept;
76
  size_type max_size() const noexcept;
77
- void resize(size_type sz, bool c = false);
78
  size_type capacity() const noexcept;
79
- bool empty() const noexcept;
80
  void reserve(size_type n);
81
  void shrink_to_fit();
82
 
83
  // element access:
84
  reference operator[](size_type n);
@@ -89,11 +90,11 @@ namespace std {
89
  const_reference front() const;
90
  reference back();
91
  const_reference back() const;
92
 
93
  // modifiers:
94
- template <class... Args> void emplace_back(Args&&... args);
95
  void push_back(const bool& x);
96
  void pop_back();
97
  template <class... Args> iterator emplace(const_iterator position, Args&&... args);
98
  iterator insert(const_iterator position, const bool& x);
99
  iterator insert(const_iterator position, size_type n, const bool& x);
@@ -113,21 +114,21 @@ namespace std {
113
  ```
114
 
115
  Unless described below, all operations have the same requirements and
116
  semantics as the primary `vector` template, except that operations
117
  dealing with the `bool` value type map to bit values in the container
118
- storage and allocator_traits::construct ([[allocator.traits.members]])
119
- is not used to construct these values.
120
 
121
  There is no requirement that the data be stored as a contiguous
122
  allocation of `bool` values. A space-optimized representation of bits is
123
  recommended instead.
124
 
125
  `reference`
126
 
127
  is a class that simulates the behavior of references of a single bit in
128
- `vector<bool>`. The conversion operator returns `true` when the bit is
129
  set, and `false` otherwise. The assignment operator sets the bit when
130
  the argument is (convertible to) `true` and clears it otherwise. `flip`
131
  reverses the state of the bit.
132
 
133
  ``` cpp
@@ -138,11 +139,11 @@ void flip() noexcept;
138
 
139
  ``` cpp
140
  static void swap(reference x, reference y) noexcept;
141
  ```
142
 
143
- *Effects:* exchanges the contents of `x` and `y` as if by
144
 
145
  ``` cpp
146
  bool b = x;
147
  x = y;
148
  y = b;
@@ -150,8 +151,7 @@ y = b;
150
 
151
  ``` cpp
152
  template <class Allocator> struct hash<vector<bool, Allocator>>;
153
  ```
154
 
155
- The template specialization shall meet the requirements of class
156
- template `hash` ([[unord.hash]]).
157
 
 
3
  To optimize space allocation, a specialization of vector for `bool`
4
  elements is provided:
5
 
6
  ``` cpp
7
  namespace std {
8
+ template <class Allocator>
9
+ class vector<bool, Allocator> {
10
  public:
11
  // types:
12
+ using value_type = bool;
13
+ using allocator_type = Allocator;
14
+ using pointer = implementation-defined;
15
+ using const_pointer = implementation-defined;
16
+ using const_reference = bool;
17
+ using size_type = implementation-defined; // see [container.requirements]
18
+ using difference_type = implementation-defined; // see [container.requirements]
19
+ using iterator = implementation-defined // type of vector<bool>::iterator; // see [container.requirements]
20
+ using const_iterator = implementation-defined // type of vector<bool>::const_iterator; // see [container.requirements]
21
+ using reverse_iterator = std::reverse_iterator<iterator>;
22
+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
23
 
24
  // bit reference:
25
  class reference {
26
  friend class vector;
27
  reference() noexcept;
 
71
  const_iterator cend() const noexcept;
72
  const_reverse_iterator crbegin() const noexcept;
73
  const_reverse_iterator crend() const noexcept;
74
 
75
  // capacity:
76
+ bool empty() const noexcept;
77
  size_type size() const noexcept;
78
  size_type max_size() const noexcept;
 
79
  size_type capacity() const noexcept;
80
+ void resize(size_type sz, bool c = false);
81
  void reserve(size_type n);
82
  void shrink_to_fit();
83
 
84
  // element access:
85
  reference operator[](size_type n);
 
90
  const_reference front() const;
91
  reference back();
92
  const_reference back() const;
93
 
94
  // modifiers:
95
+ template <class... Args> reference emplace_back(Args&&... args);
96
  void push_back(const bool& x);
97
  void pop_back();
98
  template <class... Args> iterator emplace(const_iterator position, Args&&... args);
99
  iterator insert(const_iterator position, const bool& x);
100
  iterator insert(const_iterator position, size_type n, const bool& x);
 
114
  ```
115
 
116
  Unless described below, all operations have the same requirements and
117
  semantics as the primary `vector` template, except that operations
118
  dealing with the `bool` value type map to bit values in the container
119
+ storage and `allocator_traits::construct` (
120
+ [[allocator.traits.members]]) is not used to construct these values.
121
 
122
  There is no requirement that the data be stored as a contiguous
123
  allocation of `bool` values. A space-optimized representation of bits is
124
  recommended instead.
125
 
126
  `reference`
127
 
128
  is a class that simulates the behavior of references of a single bit in
129
+ `vector<bool>`. The conversion function returns `true` when the bit is
130
  set, and `false` otherwise. The assignment operator sets the bit when
131
  the argument is (convertible to) `true` and clears it otherwise. `flip`
132
  reverses the state of the bit.
133
 
134
  ``` cpp
 
139
 
140
  ``` cpp
141
  static void swap(reference x, reference y) noexcept;
142
  ```
143
 
144
+ *Effects:* Exchanges the contents of `x` and `y` as if by:
145
 
146
  ``` cpp
147
  bool b = x;
148
  x = y;
149
  y = b;
 
151
 
152
  ``` cpp
153
  template <class Allocator> struct hash<vector<bool, Allocator>>;
154
  ```
155
 
156
+ The specialization is enabled ([[unord.hash]]).
 
157