This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

62
cppdraft/bitmask/types.md Normal file
View File

@@ -0,0 +1,62 @@
[bitmask.types]
# 16 Library introduction [[library]](./#library)
## 16.3 Method of description [[description]](description#bitmask.types)
### 16.3.3 Other conventions [[conventions]](conventions#bitmask.types)
#### 16.3.3.3 Type descriptions [[type.descriptions]](type.descriptions#bitmask.types)
#### 16.3.3.3.3 Bitmask types [bitmask.types]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L636)
Several types defined in [[support]](support "17Language support library") through [[exec]](exec "33Execution control library") and [[depr]](depr "Annex D(normative)Compatibility features") are[*bitmask types*](#def:type,bitmask "16.3.3.3.3Bitmask types[bitmask.types]")[.](#1.sentence-1)
Each bitmask type can be implemented as an
enumerated type that overloads certain operators, as an integer type,
or as a[bitset](template.bitset "22.9.2Class template bitset[template.bitset]")[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L646)
The bitmask type *bitmask* can be written:// For exposition only.// int_type is an integral type capable of representing all values of the bitmask type.enum *bitmask* : int_type {V0 = 1 << 0, V1 = 1 << 1, V2 = 1 << 2, V3 = 1 << 3, …};
inline constexpr bitmask C0(V0);inline constexpr bitmask C1(V1);inline constexpr bitmask C2(V2);inline constexpr bitmask C3(V3);
constexpr *bitmask* operator&(*bitmask* X, *bitmask* Y) {return static_cast<*bitmask*>(static_cast<int_type>(X) & static_cast<int_type>(Y));}constexpr *bitmask* operator|(*bitmask* X, *bitmask* Y) {return static_cast<*bitmask*>(static_cast<int_type>(X) | static_cast<int_type>(Y));}constexpr *bitmask* operator^(*bitmask* X, *bitmask* Y) {return static_cast<*bitmask*>(static_cast<int_type>(X) ^ static_cast<int_type>(Y));}constexpr *bitmask* operator~(*bitmask* X) {return static_cast<*bitmask*>(~static_cast<int_type>(X));}*bitmask*& operator&=(*bitmask*& X, *bitmask* Y) { X = X & Y; return X;}*bitmask*& operator|=(*bitmask*& X, *bitmask* Y) { X = X | Y; return X;}*bitmask*& operator^=(*bitmask*& X, *bitmask* Y) { X = X ^ Y; return X;}
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L687)
Here, the names C0,C1, etc. represent[*bitmask elements*](#def:bitmask,element "16.3.3.3.3Bitmask types[bitmask.types]") for this particular bitmask type[.](#3.sentence-1)
All such elements have distinct, nonzero values such that, for any pair Ci and Cj where i ≠j, Ci & Ci is nonzero andCi & Cj is zero[.](#3.sentence-2)
Additionally, the value 0 is used to represent an [*empty bitmask*](#def:bitmask,empty "16.3.3.3.3Bitmask types[bitmask.types]"), in which no
bitmask elements are set[.](#3.sentence-3)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L699)
The following terms apply to objects and values of
bitmask types:
- [(4.1)](#4.1)
To [*set*](#def:bitmask,value,set "16.3.3.3.3Bitmask types[bitmask.types]") a value *Y* in an object *X* is to evaluate the expression *X* |= *Y*[.](#4.1.sentence-1)
- [(4.2)](#4.2)
To [*clear*](#def:bitmask,value,clear "16.3.3.3.3Bitmask types[bitmask.types]") a value *Y* in an object*X* is to evaluate the expression *X* &= ~*Y*[.](#4.2.sentence-1)
- [(4.3)](#4.3)
The value *Y* [*is set*](#def:bitmask,value,is_set "16.3.3.3.3Bitmask types[bitmask.types]") in the object*X* if the expression *X* & *Y* is nonzero[.](#4.3.sentence-1)