tmp/tmptfj8aoqd/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### General <a id="template.bitset.general">[[template.bitset.general]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std {
|
| 5 |
+
template<size_t N> class bitset {
|
| 6 |
+
public:
|
| 7 |
+
// bit reference
|
| 8 |
+
class reference {
|
| 9 |
+
friend class bitset;
|
| 10 |
+
constexpr reference() noexcept;
|
| 11 |
+
|
| 12 |
+
public:
|
| 13 |
+
constexpr reference(const reference&) = default;
|
| 14 |
+
constexpr ~reference();
|
| 15 |
+
constexpr reference& operator=(bool x) noexcept; // for b[i] = x;
|
| 16 |
+
constexpr reference& operator=(const reference&) noexcept; // for b[i] = b[j];
|
| 17 |
+
constexpr bool operator~() const noexcept; // flips the bit
|
| 18 |
+
constexpr operator bool() const noexcept; // for x = b[i];
|
| 19 |
+
constexpr reference& flip() noexcept; // for b[i].flip();
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
// [bitset.cons], constructors
|
| 23 |
+
constexpr bitset() noexcept;
|
| 24 |
+
constexpr bitset(unsigned long long val) noexcept;
|
| 25 |
+
template<class charT, class traits, class Allocator>
|
| 26 |
+
constexpr explicit bitset(
|
| 27 |
+
const basic_string<charT, traits, Allocator>& str,
|
| 28 |
+
typename basic_string<charT, traits, Allocator>::size_type pos = 0,
|
| 29 |
+
typename basic_string<charT, traits, Allocator>::size_type n
|
| 30 |
+
= basic_string<charT, traits, Allocator>::npos,
|
| 31 |
+
charT zero = charT('0'),
|
| 32 |
+
charT one = charT('1'));
|
| 33 |
+
template<class charT>
|
| 34 |
+
constexpr explicit bitset(
|
| 35 |
+
const charT* str,
|
| 36 |
+
typename basic_string<charT>::size_type n = basic_string<charT>::npos,
|
| 37 |
+
charT zero = charT('0'),
|
| 38 |
+
charT one = charT('1'));
|
| 39 |
+
|
| 40 |
+
// [bitset.members], bitset operations
|
| 41 |
+
constexpr bitset& operator&=(const bitset& rhs) noexcept;
|
| 42 |
+
constexpr bitset& operator|=(const bitset& rhs) noexcept;
|
| 43 |
+
constexpr bitset& operator^=(const bitset& rhs) noexcept;
|
| 44 |
+
constexpr bitset& operator<<=(size_t pos) noexcept;
|
| 45 |
+
constexpr bitset& operator>>=(size_t pos) noexcept;
|
| 46 |
+
constexpr bitset operator<<(size_t pos) const noexcept;
|
| 47 |
+
constexpr bitset operator>>(size_t pos) const noexcept;
|
| 48 |
+
constexpr bitset& set() noexcept;
|
| 49 |
+
constexpr bitset& set(size_t pos, bool val = true);
|
| 50 |
+
constexpr bitset& reset() noexcept;
|
| 51 |
+
constexpr bitset& reset(size_t pos);
|
| 52 |
+
constexpr bitset operator~() const noexcept;
|
| 53 |
+
constexpr bitset& flip() noexcept;
|
| 54 |
+
constexpr bitset& flip(size_t pos);
|
| 55 |
+
|
| 56 |
+
// element access
|
| 57 |
+
constexpr bool operator[](size_t pos) const;
|
| 58 |
+
constexpr reference operator[](size_t pos);
|
| 59 |
+
|
| 60 |
+
constexpr unsigned long to_ulong() const;
|
| 61 |
+
constexpr unsigned long long to_ullong() const;
|
| 62 |
+
template<class charT = char,
|
| 63 |
+
class traits = char_traits<charT>,
|
| 64 |
+
class Allocator = allocator<charT>>
|
| 65 |
+
constexpr basic_string<charT, traits, Allocator>
|
| 66 |
+
to_string(charT zero = charT('0'), charT one = charT('1')) const;
|
| 67 |
+
|
| 68 |
+
// observers
|
| 69 |
+
constexpr size_t count() const noexcept;
|
| 70 |
+
constexpr size_t size() const noexcept;
|
| 71 |
+
constexpr bool operator==(const bitset& rhs) const noexcept;
|
| 72 |
+
constexpr bool test(size_t pos) const;
|
| 73 |
+
constexpr bool all() const noexcept;
|
| 74 |
+
constexpr bool any() const noexcept;
|
| 75 |
+
constexpr bool none() const noexcept;
|
| 76 |
+
};
|
| 77 |
+
|
| 78 |
+
// [bitset.hash], hash support
|
| 79 |
+
template<class T> struct hash;
|
| 80 |
+
template<size_t N> struct hash<bitset<N>>;
|
| 81 |
+
}
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
The class template `bitset<N>` describes an object that can store a
|
| 85 |
+
sequence consisting of a fixed number of bits, `N`.
|
| 86 |
+
|
| 87 |
+
Each bit represents either the value zero (reset) or one (set). To
|
| 88 |
+
*toggle* a bit is to change the value zero to one, or the value one to
|
| 89 |
+
zero. Each bit has a non-negative position `pos`. When converting
|
| 90 |
+
between an object of class `bitset<N>` and a value of some integral
|
| 91 |
+
type, bit position `pos` corresponds to the *bit value* `1 << pos`. The
|
| 92 |
+
integral value corresponding to two or more bits is the sum of their bit
|
| 93 |
+
values.
|
| 94 |
+
|
| 95 |
+
The functions described in [[template.bitset]] can report three kinds of
|
| 96 |
+
errors, each associated with a distinct exception:
|
| 97 |
+
|
| 98 |
+
- an *invalid-argument* error is associated with exceptions of type
|
| 99 |
+
`invalid_argument` [[invalid.argument]];
|
| 100 |
+
- an *out-of-range* error is associated with exceptions of type
|
| 101 |
+
`out_of_range` [[out.of.range]];
|
| 102 |
+
- an *overflow* error is associated with exceptions of type
|
| 103 |
+
`overflow_error` [[overflow.error]].
|
| 104 |
+
|