C + + Bitset usage

Source: Internet
Author: User
Tags bitset
Std::bitsetC + + Utilities library Std::bitset
Defined in Header <bitset>
template< std::size_t N >
Class Bitset;

The class template Bitset represents a fixed-size sequence of N bits. Bitsets can is manipulated by standard logic operators and converted to and from strings.

Bitset meets the requirements of copyconstructible and copyassignable. Template Parameters

N - The number of bits to allocate storage for
Member Types
Reference Proxy class representing a reference to a bit
(Class)
Member functions
(constructor) Constructs the Bitset
(Public member function)
operator==operator!= Compares the contents
(Public member function)
Element Access
Operator[] Accesses specific bit
(Public member function)
Test Accesses specific bit
(Public member function)
Allanynone (C++11) Checks if all, any or none bits are set to True
(Public member function)
Count Returns the number of bits set to True
(Public member function)
Capacity
Size Returns the size number of bits that the bitset can hold
(Public member function)
modifiers
operator&=operator|=operator^=operator~ Performs binary and, or, XOR and not
(Public member function)
Operator<<=operator>>=operator<<operator>> Performs binary shift left and shift right
(Public member function)
Set Sets bits to true or given value
(Public member function)
Reset Sets bits to False
(Public member function)
Flip Toggles the values of bits
(Public member function)
Conversions
To_string Returns a string representation of the data
(Public member function)
To_ulong Returns an unsigned long integer representation of the data
(Public member function)
To_ullong (C++11) Returns an unsigned long long integer representation of the data
(Public member function)
Non-member Functions
operator&operator|operator^ performs binary logic operations on Bitse TS&NBSP
(function template)
operator<<operator>> performs St Ream input and output of bitsets 
(function template)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.