[#bsl-bitset-2constructor-03]
= xref:bsl.adoc[bsl]::xref:bsl/bitset.adoc[bitset]::bitset
:relfileprefix: ../../
:mrdocs:

Create a bitset from characters in the specified `str`&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;bitset&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class CHAR&lowbar;TYPE,
    class TRAITS,
    class ALLOCATOR&gt;
explicit
bitset(
    std::basic&lowbar;string&lt;CHAR&lowbar;TYPE, TRAITS, ALLOCATOR&gt; const& str,
    std::basic&lowbar;string&lt;CHAR&lowbar;TYPE, TRAITS, ALLOCATOR&gt;::size&lowbar;type pos = 0,
    std::basic&lowbar;string&lt;CHAR&lowbar;TYPE, TRAITS, ALLOCATOR&gt;::size&lowbar;type n = std&colon;&colon;basic&lowbar;string&lt;CHAR&lowbar;TYPE, TRAITS, ALLOCATOR&gt;&colon;&colon;npos,
    CHAR&lowbar;TYPE zeroChar = CHAR&lowbar;TYPE(&apos;0&apos;),
    CHAR&lowbar;TYPE oneChar = CHAR&lowbar;TYPE(&apos;1&apos;));
----

== Description

Create a bitset with its first `M` bit positions corresponding to the characters in the specified `pos` of the specified `str`&period; `M` is the smaller of the parameterized `N` and `str&period;length()`&period; If `M &lt; N`, the remaining bit positions are initialized to 0&period; Characters with the value `zeroChar` correspond to an unset bit and characters with the value `oneChar` correspond to a set bit&period; The behavior is undefined if any characters in `str` is neither the specified `zeroChar` nor the specified `oneChar`&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *str*
| character sequence providing bit values
| *pos*
| starting index in `str` (default 0)
| *n*
| maximum number of characters to use (default npos)
| *zeroChar*
| character representing an unset bit (default &apos;0&apos;)
| *oneChar*
| character representing a set bit (default &apos;1&apos;)
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
