tmp/tmpjs42qivd/{from.md → to.md}
RENAMED
|
@@ -1,36 +1,36 @@
|
|
| 1 |
#### Members <a id="bitset.members">[[bitset.members]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
-
bitset
|
| 5 |
```
|
| 6 |
|
| 7 |
*Effects:* Clears each bit in `*this` for which the corresponding bit in
|
| 8 |
`rhs` is clear, and leaves all other bits unchanged.
|
| 9 |
|
| 10 |
*Returns:* `*this`.
|
| 11 |
|
| 12 |
``` cpp
|
| 13 |
-
bitset
|
| 14 |
```
|
| 15 |
|
| 16 |
*Effects:* Sets each bit in `*this` for which the corresponding bit in
|
| 17 |
`rhs` is set, and leaves all other bits unchanged.
|
| 18 |
|
| 19 |
*Returns:* `*this`.
|
| 20 |
|
| 21 |
``` cpp
|
| 22 |
-
bitset
|
| 23 |
```
|
| 24 |
|
| 25 |
*Effects:* Toggles each bit in `*this` for which the corresponding bit
|
| 26 |
in `rhs` is set, and leaves all other bits unchanged.
|
| 27 |
|
| 28 |
*Returns:* `*this`.
|
| 29 |
|
| 30 |
``` cpp
|
| 31 |
-
bitset
|
| 32 |
```
|
| 33 |
|
| 34 |
*Effects:* Replaces each bit at position `I` in `*this` with a value
|
| 35 |
determined as follows:
|
| 36 |
|
|
@@ -39,11 +39,11 @@ determined as follows:
|
|
| 39 |
position `I - pos`.
|
| 40 |
|
| 41 |
*Returns:* `*this`.
|
| 42 |
|
| 43 |
``` cpp
|
| 44 |
-
bitset
|
| 45 |
```
|
| 46 |
|
| 47 |
*Effects:* Replaces each bit at position `I` in `*this` with a value
|
| 48 |
determined as follows:
|
| 49 |
|
|
@@ -52,19 +52,31 @@ determined as follows:
|
|
| 52 |
position `I + pos`.
|
| 53 |
|
| 54 |
*Returns:* `*this`.
|
| 55 |
|
| 56 |
``` cpp
|
| 57 |
-
bitset
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
```
|
| 59 |
|
| 60 |
*Effects:* Sets all bits in `*this`.
|
| 61 |
|
| 62 |
*Returns:* `*this`.
|
| 63 |
|
| 64 |
``` cpp
|
| 65 |
-
bitset
|
| 66 |
```
|
| 67 |
|
| 68 |
*Effects:* Stores a new value in the bit at position `pos` in `*this`.
|
| 69 |
If `val` is `true`, the stored value is one, otherwise it is zero.
|
| 70 |
|
|
@@ -72,67 +84,95 @@ If `val` is `true`, the stored value is one, otherwise it is zero.
|
|
| 72 |
|
| 73 |
*Throws:* `out_of_range` if `pos` does not correspond to a valid bit
|
| 74 |
position.
|
| 75 |
|
| 76 |
``` cpp
|
| 77 |
-
bitset
|
| 78 |
```
|
| 79 |
|
| 80 |
*Effects:* Resets all bits in `*this`.
|
| 81 |
|
| 82 |
*Returns:* `*this`.
|
| 83 |
|
| 84 |
``` cpp
|
| 85 |
-
bitset
|
| 86 |
```
|
| 87 |
|
| 88 |
*Effects:* Resets the bit at position `pos` in `*this`.
|
| 89 |
|
| 90 |
*Returns:* `*this`.
|
| 91 |
|
| 92 |
*Throws:* `out_of_range` if `pos` does not correspond to a valid bit
|
| 93 |
position.
|
| 94 |
|
| 95 |
``` cpp
|
| 96 |
-
bitset
|
| 97 |
```
|
| 98 |
|
| 99 |
-
*Effects:* Constructs an object `x` of class `bitset
|
| 100 |
-
|
| 101 |
|
| 102 |
*Returns:* `x.flip()`.
|
| 103 |
|
| 104 |
``` cpp
|
| 105 |
-
bitset
|
| 106 |
```
|
| 107 |
|
| 108 |
*Effects:* Toggles all bits in `*this`.
|
| 109 |
|
| 110 |
*Returns:* `*this`.
|
| 111 |
|
| 112 |
``` cpp
|
| 113 |
-
bitset
|
| 114 |
```
|
| 115 |
|
| 116 |
*Effects:* Toggles the bit at position `pos` in `*this`.
|
| 117 |
|
| 118 |
*Returns:* `*this`.
|
| 119 |
|
| 120 |
*Throws:* `out_of_range` if `pos` does not correspond to a valid bit
|
| 121 |
position.
|
| 122 |
|
| 123 |
``` cpp
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
```
|
| 126 |
|
| 127 |
*Returns:* `x`.
|
| 128 |
|
| 129 |
*Throws:* `overflow_error` if the integral value `x` corresponding to
|
| 130 |
the bits in `*this` cannot be represented as type `unsigned long`.
|
| 131 |
|
| 132 |
``` cpp
|
| 133 |
-
unsigned long long to_ullong() const;
|
| 134 |
```
|
| 135 |
|
| 136 |
*Returns:* `x`.
|
| 137 |
|
| 138 |
*Throws:* `overflow_error` if the integral value `x` corresponding to
|
|
@@ -140,11 +180,11 @@ the bits in `*this` cannot be represented as type `unsigned long long`.
|
|
| 140 |
|
| 141 |
``` cpp
|
| 142 |
template<class charT = char,
|
| 143 |
class traits = char_traits<charT>,
|
| 144 |
class Allocator = allocator<charT>>
|
| 145 |
-
basic_string<charT, traits, Allocator>
|
| 146 |
to_string(charT zero = charT('0'), charT one = charT('1')) const;
|
| 147 |
```
|
| 148 |
|
| 149 |
*Effects:* Constructs a string object of the appropriate type and
|
| 150 |
initializes it to a string of length `N` characters. Each character is
|
|
@@ -155,11 +195,11 @@ Bit value zero becomes the character `zero`, bit value one becomes the
|
|
| 155 |
character `one`.
|
| 156 |
|
| 157 |
*Returns:* The created object.
|
| 158 |
|
| 159 |
``` cpp
|
| 160 |
-
size_t count() const noexcept;
|
| 161 |
```
|
| 162 |
|
| 163 |
*Returns:* A count of the number of bits set in `*this`.
|
| 164 |
|
| 165 |
``` cpp
|
|
@@ -167,79 +207,39 @@ constexpr size_t size() const noexcept;
|
|
| 167 |
```
|
| 168 |
|
| 169 |
*Returns:* `N`.
|
| 170 |
|
| 171 |
``` cpp
|
| 172 |
-
bool operator==(const bitset
|
| 173 |
```
|
| 174 |
|
| 175 |
*Returns:* `true` if the value of each bit in `*this` equals the value
|
| 176 |
of the corresponding bit in `rhs`.
|
| 177 |
|
| 178 |
``` cpp
|
| 179 |
-
bool test(size_t pos) const;
|
| 180 |
```
|
| 181 |
|
| 182 |
*Returns:* `true` if the bit at position `pos` in `*this` has the value
|
| 183 |
one.
|
| 184 |
|
| 185 |
*Throws:* `out_of_range` if `pos` does not correspond to a valid bit
|
| 186 |
position.
|
| 187 |
|
| 188 |
``` cpp
|
| 189 |
-
bool all() const noexcept;
|
| 190 |
```
|
| 191 |
|
| 192 |
*Returns:* `count() == size()`.
|
| 193 |
|
| 194 |
``` cpp
|
| 195 |
-
bool any() const noexcept;
|
| 196 |
```
|
| 197 |
|
| 198 |
*Returns:* `count() != 0`.
|
| 199 |
|
| 200 |
``` cpp
|
| 201 |
-
bool none() const noexcept;
|
| 202 |
```
|
| 203 |
|
| 204 |
*Returns:* `count() == 0`.
|
| 205 |
|
| 206 |
-
``` cpp
|
| 207 |
-
bitset<N> operator<<(size_t pos) const noexcept;
|
| 208 |
-
```
|
| 209 |
-
|
| 210 |
-
*Returns:* `bitset<N>(*this) <<= pos`.
|
| 211 |
-
|
| 212 |
-
``` cpp
|
| 213 |
-
bitset<N> operator>>(size_t pos) const noexcept;
|
| 214 |
-
```
|
| 215 |
-
|
| 216 |
-
*Returns:* `bitset<N>(*this) >>= pos`.
|
| 217 |
-
|
| 218 |
-
``` cpp
|
| 219 |
-
constexpr bool operator[](size_t pos) const;
|
| 220 |
-
```
|
| 221 |
-
|
| 222 |
-
*Preconditions:* `pos` is valid.
|
| 223 |
-
|
| 224 |
-
*Returns:* `true` if the bit at position `pos` in `*this` has the value
|
| 225 |
-
one, otherwise `false`.
|
| 226 |
-
|
| 227 |
-
*Throws:* Nothing.
|
| 228 |
-
|
| 229 |
-
``` cpp
|
| 230 |
-
bitset<N>::reference operator[](size_t pos);
|
| 231 |
-
```
|
| 232 |
-
|
| 233 |
-
*Preconditions:* `pos` is valid.
|
| 234 |
-
|
| 235 |
-
*Returns:* An object of type `bitset<N>::reference` such that
|
| 236 |
-
`(*this)[pos] == this->test(pos)`, and such that `(*this)[pos] = val` is
|
| 237 |
-
equivalent to `this->set(pos, val)`.
|
| 238 |
-
|
| 239 |
-
*Throws:* Nothing.
|
| 240 |
-
|
| 241 |
-
*Remarks:* For the purpose of determining the presence of a data
|
| 242 |
-
race [[intro.multithread]], any access or update through the resulting
|
| 243 |
-
reference potentially accesses or modifies, respectively, the entire
|
| 244 |
-
underlying bitset.
|
| 245 |
-
|
|
|
|
| 1 |
#### Members <a id="bitset.members">[[bitset.members]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
+
constexpr bitset& operator&=(const bitset& rhs) noexcept;
|
| 5 |
```
|
| 6 |
|
| 7 |
*Effects:* Clears each bit in `*this` for which the corresponding bit in
|
| 8 |
`rhs` is clear, and leaves all other bits unchanged.
|
| 9 |
|
| 10 |
*Returns:* `*this`.
|
| 11 |
|
| 12 |
``` cpp
|
| 13 |
+
constexpr bitset& operator|=(const bitset& rhs) noexcept;
|
| 14 |
```
|
| 15 |
|
| 16 |
*Effects:* Sets each bit in `*this` for which the corresponding bit in
|
| 17 |
`rhs` is set, and leaves all other bits unchanged.
|
| 18 |
|
| 19 |
*Returns:* `*this`.
|
| 20 |
|
| 21 |
``` cpp
|
| 22 |
+
constexpr bitset& operator^=(const bitset& rhs) noexcept;
|
| 23 |
```
|
| 24 |
|
| 25 |
*Effects:* Toggles each bit in `*this` for which the corresponding bit
|
| 26 |
in `rhs` is set, and leaves all other bits unchanged.
|
| 27 |
|
| 28 |
*Returns:* `*this`.
|
| 29 |
|
| 30 |
``` cpp
|
| 31 |
+
constexpr bitset& operator<<=(size_t pos) noexcept;
|
| 32 |
```
|
| 33 |
|
| 34 |
*Effects:* Replaces each bit at position `I` in `*this` with a value
|
| 35 |
determined as follows:
|
| 36 |
|
|
|
|
| 39 |
position `I - pos`.
|
| 40 |
|
| 41 |
*Returns:* `*this`.
|
| 42 |
|
| 43 |
``` cpp
|
| 44 |
+
constexpr bitset& operator>>=(size_t pos) noexcept;
|
| 45 |
```
|
| 46 |
|
| 47 |
*Effects:* Replaces each bit at position `I` in `*this` with a value
|
| 48 |
determined as follows:
|
| 49 |
|
|
|
|
| 52 |
position `I + pos`.
|
| 53 |
|
| 54 |
*Returns:* `*this`.
|
| 55 |
|
| 56 |
``` cpp
|
| 57 |
+
constexpr bitset operator<<(size_t pos) const noexcept;
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
*Returns:* `bitset(*this) <<= pos`.
|
| 61 |
+
|
| 62 |
+
``` cpp
|
| 63 |
+
constexpr bitset operator>>(size_t pos) const noexcept;
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
*Returns:* `bitset(*this) >>= pos`.
|
| 67 |
+
|
| 68 |
+
``` cpp
|
| 69 |
+
constexpr bitset& set() noexcept;
|
| 70 |
```
|
| 71 |
|
| 72 |
*Effects:* Sets all bits in `*this`.
|
| 73 |
|
| 74 |
*Returns:* `*this`.
|
| 75 |
|
| 76 |
``` cpp
|
| 77 |
+
constexpr bitset& set(size_t pos, bool val = true);
|
| 78 |
```
|
| 79 |
|
| 80 |
*Effects:* Stores a new value in the bit at position `pos` in `*this`.
|
| 81 |
If `val` is `true`, the stored value is one, otherwise it is zero.
|
| 82 |
|
|
|
|
| 84 |
|
| 85 |
*Throws:* `out_of_range` if `pos` does not correspond to a valid bit
|
| 86 |
position.
|
| 87 |
|
| 88 |
``` cpp
|
| 89 |
+
constexpr bitset& reset() noexcept;
|
| 90 |
```
|
| 91 |
|
| 92 |
*Effects:* Resets all bits in `*this`.
|
| 93 |
|
| 94 |
*Returns:* `*this`.
|
| 95 |
|
| 96 |
``` cpp
|
| 97 |
+
constexpr bitset& reset(size_t pos);
|
| 98 |
```
|
| 99 |
|
| 100 |
*Effects:* Resets the bit at position `pos` in `*this`.
|
| 101 |
|
| 102 |
*Returns:* `*this`.
|
| 103 |
|
| 104 |
*Throws:* `out_of_range` if `pos` does not correspond to a valid bit
|
| 105 |
position.
|
| 106 |
|
| 107 |
``` cpp
|
| 108 |
+
constexpr bitset operator~() const noexcept;
|
| 109 |
```
|
| 110 |
|
| 111 |
+
*Effects:* Constructs an object `x` of class `bitset` and initializes it
|
| 112 |
+
with `*this`.
|
| 113 |
|
| 114 |
*Returns:* `x.flip()`.
|
| 115 |
|
| 116 |
``` cpp
|
| 117 |
+
constexpr bitset& flip() noexcept;
|
| 118 |
```
|
| 119 |
|
| 120 |
*Effects:* Toggles all bits in `*this`.
|
| 121 |
|
| 122 |
*Returns:* `*this`.
|
| 123 |
|
| 124 |
``` cpp
|
| 125 |
+
constexpr bitset& flip(size_t pos);
|
| 126 |
```
|
| 127 |
|
| 128 |
*Effects:* Toggles the bit at position `pos` in `*this`.
|
| 129 |
|
| 130 |
*Returns:* `*this`.
|
| 131 |
|
| 132 |
*Throws:* `out_of_range` if `pos` does not correspond to a valid bit
|
| 133 |
position.
|
| 134 |
|
| 135 |
``` cpp
|
| 136 |
+
constexpr bool operator[](size_t pos) const;
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
*Preconditions:* `pos` is valid.
|
| 140 |
+
|
| 141 |
+
*Returns:* `true` if the bit at position `pos` in `*this` has the value
|
| 142 |
+
one, otherwise `false`.
|
| 143 |
+
|
| 144 |
+
*Throws:* Nothing.
|
| 145 |
+
|
| 146 |
+
``` cpp
|
| 147 |
+
constexpr bitset::reference operator[](size_t pos);
|
| 148 |
+
```
|
| 149 |
+
|
| 150 |
+
*Preconditions:* `pos` is valid.
|
| 151 |
+
|
| 152 |
+
*Returns:* An object of type `bitset::reference` such that
|
| 153 |
+
`(*this)[pos] == this->test(pos)`, and such that `(*this)[pos] = val` is
|
| 154 |
+
equivalent to `this->set(pos, val)`.
|
| 155 |
+
|
| 156 |
+
*Throws:* Nothing.
|
| 157 |
+
|
| 158 |
+
*Remarks:* For the purpose of determining the presence of a data
|
| 159 |
+
race [[intro.multithread]], any access or update through the resulting
|
| 160 |
+
reference potentially accesses or modifies, respectively, the entire
|
| 161 |
+
underlying bitset.
|
| 162 |
+
|
| 163 |
+
``` cpp
|
| 164 |
+
constexpr unsigned long to_ulong() const;
|
| 165 |
```
|
| 166 |
|
| 167 |
*Returns:* `x`.
|
| 168 |
|
| 169 |
*Throws:* `overflow_error` if the integral value `x` corresponding to
|
| 170 |
the bits in `*this` cannot be represented as type `unsigned long`.
|
| 171 |
|
| 172 |
``` cpp
|
| 173 |
+
constexpr unsigned long long to_ullong() const;
|
| 174 |
```
|
| 175 |
|
| 176 |
*Returns:* `x`.
|
| 177 |
|
| 178 |
*Throws:* `overflow_error` if the integral value `x` corresponding to
|
|
|
|
| 180 |
|
| 181 |
``` cpp
|
| 182 |
template<class charT = char,
|
| 183 |
class traits = char_traits<charT>,
|
| 184 |
class Allocator = allocator<charT>>
|
| 185 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 186 |
to_string(charT zero = charT('0'), charT one = charT('1')) const;
|
| 187 |
```
|
| 188 |
|
| 189 |
*Effects:* Constructs a string object of the appropriate type and
|
| 190 |
initializes it to a string of length `N` characters. Each character is
|
|
|
|
| 195 |
character `one`.
|
| 196 |
|
| 197 |
*Returns:* The created object.
|
| 198 |
|
| 199 |
``` cpp
|
| 200 |
+
constexpr size_t count() const noexcept;
|
| 201 |
```
|
| 202 |
|
| 203 |
*Returns:* A count of the number of bits set in `*this`.
|
| 204 |
|
| 205 |
``` cpp
|
|
|
|
| 207 |
```
|
| 208 |
|
| 209 |
*Returns:* `N`.
|
| 210 |
|
| 211 |
``` cpp
|
| 212 |
+
constexpr bool operator==(const bitset& rhs) const noexcept;
|
| 213 |
```
|
| 214 |
|
| 215 |
*Returns:* `true` if the value of each bit in `*this` equals the value
|
| 216 |
of the corresponding bit in `rhs`.
|
| 217 |
|
| 218 |
``` cpp
|
| 219 |
+
constexpr bool test(size_t pos) const;
|
| 220 |
```
|
| 221 |
|
| 222 |
*Returns:* `true` if the bit at position `pos` in `*this` has the value
|
| 223 |
one.
|
| 224 |
|
| 225 |
*Throws:* `out_of_range` if `pos` does not correspond to a valid bit
|
| 226 |
position.
|
| 227 |
|
| 228 |
``` cpp
|
| 229 |
+
constexpr bool all() const noexcept;
|
| 230 |
```
|
| 231 |
|
| 232 |
*Returns:* `count() == size()`.
|
| 233 |
|
| 234 |
``` cpp
|
| 235 |
+
constexpr bool any() const noexcept;
|
| 236 |
```
|
| 237 |
|
| 238 |
*Returns:* `count() != 0`.
|
| 239 |
|
| 240 |
``` cpp
|
| 241 |
+
constexpr bool none() const noexcept;
|
| 242 |
```
|
| 243 |
|
| 244 |
*Returns:* `count() == 0`.
|
| 245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|