Init
This commit is contained in:
116
cppdraft/bitset/cons.md
Normal file
116
cppdraft/bitset/cons.md
Normal file
@@ -0,0 +1,116 @@
|
||||
[bitset.cons]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.9 Bitsets [[bitset]](bitset#cons)
|
||||
|
||||
### 22.9.2 Class template bitset [[template.bitset]](template.bitset#bitset.cons)
|
||||
|
||||
#### 22.9.2.2 Constructors [bitset.cons]
|
||||
|
||||
[ð](#lib:bitset,constructor)
|
||||
|
||||
`constexpr bitset() noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10533)
|
||||
|
||||
*Effects*: Initializes all bits in *this to zero[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:bitset,constructor_)
|
||||
|
||||
`constexpr bitset(unsigned long long val) noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10544)
|
||||
|
||||
*Effects*: Initializes the first M bit positions to the corresponding bit
|
||||
values in val[.](#2.sentence-1)
|
||||
|
||||
M is the smaller of N and the number of bits in the value
|
||||
representation ([[basic.types.general]](basic.types.general#term.object.representation "6.9.1 General")) of unsigned long long[.](#2.sentence-2)
|
||||
|
||||
If M < N, the remaining bit positions are initialized to zero[.](#2.sentence-3)
|
||||
|
||||
[ð](#lib:bitset,constructor__)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr explicit bitset(
|
||||
const basic_string<charT, traits, Allocator>& str,
|
||||
typename basic_string<charT, traits, Allocator>::size_type pos = 0,
|
||||
typename basic_string<charT, traits, Allocator>::size_type n
|
||||
= basic_string<charT, traits, Allocator>::npos,
|
||||
charT zero = charT('0'),
|
||||
charT one = charT('1'));
|
||||
template<class charT, class traits>
|
||||
constexpr explicit bitset(
|
||||
basic_string_view<charT, traits> str,
|
||||
typename basic_string_view<charT, traits>::size_type pos = 0,
|
||||
typename basic_string_view<charT, traits>::size_type n
|
||||
= basic_string_view<charT, traits>::npos,
|
||||
charT zero = charT('0'),
|
||||
charT one = charT('1'));
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10574)
|
||||
|
||||
*Effects*: Determines the effective lengthrlen of the initializing string as the smaller ofn andstr.size() - pos[.](#3.sentence-1)
|
||||
|
||||
Initializes the first M bit
|
||||
positions to values determined from the corresponding characters in the stringstr[.](#3.sentence-2)
|
||||
|
||||
M is the smaller of N and rlen[.](#3.sentence-3)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10585)
|
||||
|
||||
An element of the constructed object has value zero if the
|
||||
corresponding character in str, beginning at positionpos, iszero[.](#4.sentence-1)
|
||||
|
||||
Otherwise, the element has the value one[.](#4.sentence-2)
|
||||
|
||||
Character position pos + M - 1 corresponds to bit position zero[.](#4.sentence-3)
|
||||
|
||||
Subsequent decreasing character positions correspond to increasing bit positions[.](#4.sentence-4)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10594)
|
||||
|
||||
If M < N, remaining bit positions are initialized to zero[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10597)
|
||||
|
||||
The function uses traits::eq to compare the character values[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10601)
|
||||
|
||||
*Throws*: out_of_range if pos > str.size() orinvalid_argument if any of
|
||||
the rlen characters in str beginning at position pos is other than zero or one[.](#7.sentence-1)
|
||||
|
||||
[ð](#lib:bitset,constructor___)
|
||||
|
||||
`template<class charT>
|
||||
constexpr explicit bitset(
|
||||
const charT* str,
|
||||
typename basic_string_view<charT>::size_type n = basic_string_view<charT>::npos,
|
||||
charT zero = charT('0'),
|
||||
charT one = charT('1'));
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10623)
|
||||
|
||||
*Effects*: As if by:bitset(n == basic_string_view<charT>::npos ? basic_string_view<charT>(str): basic_string_view<charT>(str, n), 0, n, zero, one)
|
||||
Reference in New Issue
Block a user