PrevUpHomeNext

Bitfield

#include <oglplus/bitfield.hpp>

The Bitfield template serves as a wrapper for OpenGL bitfields. It allows to combine strongly-typed enumerated values into a single bitfield value.

Library end-user applications rarely need to use this class directly. Instantiations of this template are used as types for parameters in functions taking bitfields based on strongly-type enumerations. When constructing a bitfield the application simply passes the enumerated value or a combination of enumerated values using the bitwise-or operator or initializer list.

template <typename Bits>
class Bitfield
{
public:
	Bitfield(void); 1
	Bitfield(Bits _bit); 2
	Bitfield(Bits _bit_a, Bits _bit_b); 3

#if !OGLPLUS_NO_INITIALIZER_LISTS
	Bitfield(const std::initializer_list<Bits>& bits); 4
#endif
	template <typename Iter>
	Bitfield(Iter pos, Iter end); 5

	friend Bitfield operator | (Bitfield bf, Bits b); 6
	Bitfield& operator |= (Bits b); 7

	bool Test(Bits b) const; 8
};

template <typename Bits>
Bitfield<Bits> operator | (Bits b1, Bits b2);

1

Constructs an empty (zero) bitfield.

2

Construct a bitfield from a single value of Bits.

3

Construct a bitfield from a pair of Bits.

4

Construct a bitfield from an initializer list of Bits.

5

Construction from a pair of iterators through Bits.

6

Bitwise-or operator for combining Bits into a bitfield.

7

Bitwise-or operator for combining Bits into a bitfield.

8

Tests if a specified bit is set.


PrevUpHomeNext