標準ライブラリヘッダ <bitset>
提供: cppreference.com
このヘッダは汎用ユーティリティライブラリの一部です。
インクルード | ||
<string> | ||
<iosfwd> | ||
クラス | ||
固定長のビット配列を実装します (クラス) | ||
(C++11) | std::bitset に対するハッシュサポート (クラステンプレートの特殊化) | |
関数 | ||
ビットセットに対してバイナリ論理演算を行います (関数テンプレート) | ||
ビットセットのストリーム入出力を行います (関数テンプレート) |
[編集]概要
#include <string>#include <iosfwd> // for istream, ostream namespace std {template<size_t N>class bitset; // bitset operators:template<size_t N> bitset<N> operator&(const bitset<N>&, const bitset<N>&)noexcept;template<size_t N> bitset<N> operator|(const bitset<N>&, const bitset<N>&)noexcept;template<size_t N> bitset<N> operator^(const bitset<N>&, const bitset<N>&)noexcept;template<class charT, class traits, size_t N> basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& is, bitset<N>& x);template<class charT, class traits, size_t N> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x); // Hash supporttemplate<class T>struct hash;template<size_t N>struct hash<bitset<N>>; }
[編集]クラス std::bitset
template<size_t N>class bitset {public:// bit reference:class reference {friendclass bitset; reference()noexcept;public: ~reference()noexcept; reference& operator=(bool x)noexcept;// for b[i] = x; reference& operator=(const reference&)noexcept;// for b[i] = b[j];bool operator~()constnoexcept;// flips the bit operator bool()constnoexcept;// for x = b[i]; reference& flip()noexcept;// for b[i].flip(); }; //constructors:constexpr bitset()noexcept;constexpr bitset(unsignedlonglong val)noexcept;template<class charT, class traits, class Allocator>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>explicit bitset(const charT* str, typename basic_string<charT>::size_type n = basic_string<charT>::npos, charT zero = charT('0'), charT one = charT('1')); // bitset operations: bitset<N>& operator&=(const bitset<N>& rhs)noexcept; bitset<N>& operator|=(const bitset<N>& rhs)noexcept; bitset<N>& operator^=(const bitset<N>& rhs)noexcept; bitset<N>& operator<<=(size_t pos)noexcept; bitset<N>& operator>>=(size_t pos)noexcept; bitset<N>& set()noexcept; bitset<N>& set(size_t pos, bool val =true); bitset<N>& reset()noexcept; bitset<N>& reset(size_t pos); bitset<N> operator~()constnoexcept; bitset<N>& flip()noexcept; bitset<N>& flip(size_t pos); // element access:constexprbool operator[](size_t pos)const;// for b[i]; reference operator[](size_t pos);// for b[i]; unsignedlong to_ulong()const;unsignedlonglong to_ullong()const;template<class charT =char, class traits = char_traits<charT>, class Allocator = allocator<charT>> basic_string<charT, traits, Allocator> to_string(charT zero = charT('0'), charT one = charT('1'))const; size_t count()constnoexcept;constexpr size_t size()noexcept; bool operator==(const bitset<N>& rhs)constnoexcept;bool operator!=(const bitset<N>& rhs)constnoexcept; bool test(size_t pos)const;bool all()constnoexcept;bool any()constnoexcept;bool none()constnoexcept; bitset<N> operator<<(size_t pos)constnoexcept; bitset<N> operator>>(size_t pos)constnoexcept;};