名前空間
変種
操作

std::bitset::bitset

提供: cppreference.com
< cpp‎ | utility‎ | bitset

 
 
ユーティリティライブラリ
支援を入力します (basic types, RTTI, type traits)
動的なメモリ管理
エラー処理
プログラムユーティリティ
可変個引数関数
日付と時刻
関数オブジェクト
initializer_list(C++11)
bitset
hash(C++11)
関係演算子
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
ペアとタプル
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair
tuple(C++11)
piecewise_construct_t(C++11)
piecewise_construct(C++11)
フォワード、スワップ、および移動
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap
forward(C++11)
move(C++11)
move_if_noexcept(C++11)
declval(C++11)
 
std::bitset
メンバータイプ
Original:
Member types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::reference
メンバ関数
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::bitset
bitset::operator==
bitset::operator!=
要素アクセスの循環参照を解除するために使用されている
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::operator[]
bitset::test
bitset::all
bitset::any
bitset::none
(C++11)

 
bitset::count
容量
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::size
修飾子
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::operator&=
bitset::operator|=
bitset::operator^=
bitset::operator~
bitset::operator<<=
bitset::operator>>=
bitset::operator<<
bitset::operator>>
bitset::set
bitset::reset
bitset::flip
変換
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::to_string
bitset::to_ulong
bitset::to_ullong(C++11)
非メンバ関数
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
operator&
operator|
operator^
operator<<
operator>>
ヘルパークラス
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::hash(C++11)
 
constexpr bitset() noexcept;
(1)
constexpr bitset( unsigned long long val ) noexcept;
(2)
template< class CharT, class Traits, class Allocator >

explicit bitset( const std::basic_string<CharT,Traits,Allocator>& str,
                 typename std::basic_string<CharT,Traits,Allocator>::size_type pos = 0,
                 typename std::basic_string<CharT,Traits,Allocator>::size_type n =
                     std::basic_string<CharT,Traits,Allocator>::npos);

         bitset( const std::basic_string<CharT,Traits,Allocator>& str,
                 typename std::basic_string<CharT,Traits,Allocator>::size_type pos = 0,
                 typename std::basic_string<CharT,Traits,Allocator>::size_type n =
                     std::basic_string<CharT,Traits,Allocator>::npos,
                 CharT zero = CharT(0),

                 CharT one = CharT(1));
(3) (C + + 11時まで)



(C + + 11以来)
template< class CharT >

explicit bitset( const CharT* str,
                 typename std::basic_string<CharT>::size_type n =
                     std::basic_string<CharT>::npos,
                 CharT zero = CharT(0),

                 CharT one = CharT(1));
(4) (C + + 11以来)
いくつかの任意のデータソースのいずれかから新しいbitsetを構築します
Original:
Constructs a new bitset from one of several optional data sources:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1。デフォルトのコンストラクタです。ゼロに設定されたすべてのビットとbitsetを構築し.
Original:
1. Default constructor. Constructs a bitset with all bits set to zero.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2。 valのビットを使用して、bitsetを構築します。 NはbitsetのとMの大きさである場合valに設定されたビットの数である場合、唯一の分(NM)ビットがBitSetに含まれるでしょう.
Original:
2. Constructs a bitset using the bits in val. If the N is the size of the bitset and M is the number of set bits in val, then only min(N, M) bits will be included in the bitset.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3。 std::basic_stringstrの文字を使用して、bitsetを構築します。オプションの開始位置と長さposnはセット(one)およびunset(zero)ビットに代替値を示すだけでなく、文字を提供することができる.
Original:
3. Constructs a bitset using the characters in the std::basic_string str. An optional starting position pos and length n can be provided, as well as characters denoting alternate values for set (one) and unset (zero) bits.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
初期化文字列の有効長は、min(nstr.size() - pos)です.
Original:
The effective length of the initializing string is min(n, str.size() - pos).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pos > str.size()場合、このコンストラクタはstd::out_of_rangeをスローします。任意の文字がstrで調べた場合zeroまたはone、それはstd::invalid_argumentスローされません.
Original:
If pos > str.size(), this constructor throws std::out_of_range. If any characters examined in str are not zero or one, it throws std::invalid_argument.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4。 (3)に似ていますが、代わりにCharT*std::basic_stringを使用しています.
Original:
4. Similar to (3), but uses a CharT* instead of a std::basic_string.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

val -
数はbitsetを初期化するために使用
Original:
number used to initialize the bitset
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
str -
文字列は、bitsetを初期化するために使用される
Original:
string used to initialize the bitset
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pos -
str内の開始オフセット
Original:
a starting offset into str
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
n -
strから、使用する文字の数
Original:
number of characters to use from str
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
one -
strで設定されたビットの代替文字
Original:
alternate character for set bits in str
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
zero -
strでしか解除ビットの代替文字
Original:
alternate character for unset bits in str
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 例外

1。なし
Original:
1. none
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2。なし
Original:
2. none
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

3. std::out_of_range if pos > str.size()

4。なし
Original:
4. none
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


[編集]

#include <bitset>
#include <string>
 
int main() 
{
    // empty constructor
    std::bitset<8> b1; // [0,0,0,0,0,0,0,0]
 
    // unsigned long long constructor
    std::bitset<8> b2(42); // [0,0,1,0,1,0,1,0]
 
    // string constructor
    std::string bit_string = "110010";
    std::bitset<8> b3(bit_string);       // [0,0,1,1,0,0,1,0]
    std::bitset<8> b4(bit_string, 2);    // [0,0,0,0,0,0,1,0]
    std::bitset<8> b5(bit_string, 2, 3); // [0,0,0,0,0,0,0,1]
 
    // string constructor using custom zero/one digits
    std::string alpha_bit_string = "aBaaBBaB";
    std::bitset<8> b6(alpha_bit_string, 0, alpha_bit_string.size(),
                      'a', 'B');         // [0,1,0,0,1,1,0,1]
 
    // char* constructor using custom digits
    std::bitset<8> b7("XXXXYYYY", 0, 'X', 'Y'); // [0,0,0,0,1,1,1,1]
    return 0;
}


[編集] も参照してください

sets bits to true or given value
(パブリックメンバ関数) [edit]
falseにビットを設定します
Original:
sets bits to false
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]