From Jason Turner

[bitmask.types]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpaffizxc4/{from.md → to.md} +18 -18
tmp/tmpaffizxc4/{from.md → to.md} RENAMED
@@ -1,49 +1,49 @@
1
  ##### Bitmask types <a id="bitmask.types">[[bitmask.types]]</a>
2
 
3
- Several types defined in Clauses  [[language.support]] through 
4
- [[thread]] and Annex  [[depr]] are *bitmask types*. Each bitmask type
5
- can be implemented as an enumerated type that overloads certain
6
- operators, as an integer type, or as a `bitset` ([[template.bitset]]).
7
 
8
- The bitmask type *bitmask* can be written:
9
 
10
  ``` cpp
11
  // For exposition only.
12
  // int_type is an integral type capable of representing all values of the bitmask type.
13
  enum bitmask : int_type {
14
- V₀ = 1 << 0, V₁ = 1 << 1, V₂ = 1 << 2, V₃ = 1 << 3, .....
15
  };
16
 
17
  inline constexpr bitmask C₀(V₀{});
18
  inline constexpr bitmask C₁(V₁{});
19
  inline constexpr bitmask C₂(V₂{});
20
  inline constexpr bitmask C₃(V₃{});
21
- .....
22
 
23
- constexpr bitmask{} operator&(bitmask{} X, bitmask{} Y) {
24
- return static_cast<bitmask{}>(
25
  static_cast<int_type>(X) & static_cast<int_type>(Y));
26
  }
27
- constexpr bitmask{} operator|(bitmask{} X, bitmask{} Y) {
28
- return static_cast<bitmask{}>(
29
  static_cast<int_type>(X) | static_cast<int_type>(Y));
30
  }
31
- constexpr bitmask{} operator^(bitmask{} X, bitmask{} Y){
32
- return static_cast<bitmask{}>(
33
  static_cast<int_type>(X) ^ static_cast<int_type>(Y));
34
  }
35
- constexpr bitmask{} operator~(bitmask{} X){
36
- return static_cast<bitmask{}>(~static_cast<int_type>(X));
37
  }
38
- bitmask{}& operator&=(bitmask{}& X, bitmask{} Y){
39
  X = X & Y; return X;
40
  }
41
- bitmask{}& operator|=(bitmask{}& X, bitmask{} Y) {
42
  X = X | Y; return X;
43
  }
44
- bitmask{}& operator^=(bitmask{}& X, bitmask{} Y) {
45
  X = X ^ Y; return X;
46
  }
47
  ```
48
 
49
  Here, the names `C₀`, `C₁`, etc. represent *bitmask elements* for this
 
1
  ##### Bitmask types <a id="bitmask.types">[[bitmask.types]]</a>
2
 
3
+ Several types defined in [[support]] through [[thread]] and [[depr]] are
4
+ *bitmask types*. Each bitmask type can be implemented as an enumerated
5
+ type that overloads certain operators, as an integer type, or as a
6
+ `bitset` [[template.bitset]].
7
 
8
+ The bitmask type `bitmask` can be written:
9
 
10
  ``` cpp
11
  // For exposition only.
12
  // int_type is an integral type capable of representing all values of the bitmask type.
13
  enum bitmask : int_type {
14
+ V₀ = 1 << 0, V₁ = 1 << 1, V₂ = 1 << 2, V₃ = 1 << 3,
15
  };
16
 
17
  inline constexpr bitmask C₀(V₀{});
18
  inline constexpr bitmask C₁(V₁{});
19
  inline constexpr bitmask C₂(V₂{});
20
  inline constexpr bitmask C₃(V₃{});
21
+
22
 
23
+ constexpr bitmask operator&(bitmask X, bitmask Y) {
24
+ return static_cast<bitmask>(
25
  static_cast<int_type>(X) & static_cast<int_type>(Y));
26
  }
27
+ constexpr bitmask operator|(bitmask X, bitmask Y) {
28
+ return static_cast<bitmask>(
29
  static_cast<int_type>(X) | static_cast<int_type>(Y));
30
  }
31
+ constexpr bitmask operator^(bitmask X, bitmask Y){
32
+ return static_cast<bitmask>(
33
  static_cast<int_type>(X) ^ static_cast<int_type>(Y));
34
  }
35
+ constexpr bitmask operator~(bitmask X){
36
+ return static_cast<bitmask>(~static_cast<int_type>(X));
37
  }
38
+ bitmask& operator&=(bitmask& X, bitmask Y){
39
  X = X & Y; return X;
40
  }
41
+ bitmask& operator|=(bitmask& X, bitmask Y) {
42
  X = X | Y; return X;
43
  }
44
+ bitmask& operator^=(bitmask& X, bitmask Y) {
45
  X = X ^ Y; return X;
46
  }
47
  ```
48
 
49
  Here, the names `C₀`, `C₁`, etc. represent *bitmask elements* for this