#include <xtl_bitflags.h>
The following code demonstrates use of xtl_bitflags
struct:
// xtl_bitflags.cpp // demonstrates cttl_impl::xtl_bitflags usage #include <iostream> #include "cttl/xtl_bitflags.h" int main() { using cttl_impl::xtl_bitflags; xtl_bitflags flags( 1 ); std::cout << "flags " << flags << std::endl; std::cout << " flags.clear( 1 ) "; flags.clear( 1 ); std::cout << std::endl; std::cout << " flags.set( 128 ) "; flags.set( 128 ); std::cout << std::endl; std::cout << " flags.test( 2 ) " << flags.test( 2 ); std::cout << std::endl; std::cout << "flags.test( 128 ) " << flags.test( 128 ); std::cout << std::endl; std::cout << " flags.set( 2 ) "; flags.set( 2 ); std::cout << std::endl; std::cout << " flags.test( 2 ) " << flags.test( 2 ); std::cout << std::endl; std::cout << " flags.clear( 2 ) "; flags.clear( 2 ); std::cout << std::endl; std::cout << " flags.test( 2 ) " << flags.test( 2 ); std::cout << std::endl; std::cout << "flags.test( 128 ) " << flags.test( 128 ); std::cout << std::endl; return 0; }
flags 1 flags.clear( 1 ) flags.set( 128 ) flags.test( 2 ) 0 flags.test( 128 ) 128 flags.set( 2 ) flags.test( 2 ) 2 flags.clear( 2 ) flags.test( 2 ) 0 flags.test( 128 ) 128
Definition at line 49 of file xtl_bitflags.h.
Public Types | |
typedef unsigned int | value_type |
Defines type that represents bits of the integer. | |
Public Member Functions | |
xtl_bitflags (value_type flags_=0) | |
Constructs new object and sets flags provided by the user. | |
value_type | clear (value_type flags_) |
Clears (sets to zero) bits specified by the caller. | |
value_type | set (value_type flags_) |
Sets bits provided by the user. | |
value_type | test (value_type flags_) const |
Tests if bits are set. | |
bool | exact_test (value_type flags_) const |
Tests flags. | |
operator value_type () const | |
Converts encapsulated bits to the xtl_bitflags::value_type . | |
Public Attributes | |
value_type | bits |
Stores encapsulated bits. |
|
Constructs new object and sets flags provided by the user.
Definition at line 60 of file xtl_bitflags.h. |
|
Clears (sets to zero) bits specified by the caller.
Definition at line 73 of file xtl_bitflags.h. |
|
Tests flags.
Definition at line 119 of file xtl_bitflags.h. |
|
Sets bits provided by the user.
Definition at line 89 of file xtl_bitflags.h. |
|
Tests if bits are set.
Definition at line 105 of file xtl_bitflags.h. |