]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Metafunctions/Bitwise Operations//bitxor_ |
2 | ||
3 | bitxor\_ | |
4 | ======== | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename T1 | |
13 | , typename T2 | |
14 | , typename T3 = |unspecified| | |
15 | |...| | |
16 | , typename T\ *n* = |unspecified| | |
17 | > | |
18 | struct bitxor\_ | |
19 | { | |
20 | typedef |unspecified| type; | |
21 | }; | |
22 | ||
23 | ||
24 | ||
25 | Description | |
26 | ----------- | |
27 | ||
28 | Returns the result of *bitwise xor* (``^``) operation of its arguments. | |
29 | ||
30 | ||
31 | Header | |
32 | ------ | |
33 | ||
34 | .. parsed-literal:: | |
35 | ||
36 | #include <boost/mpl/bitxor.hpp> | |
37 | #include <boost/mpl/bitwise.hpp> | |
38 | ||
39 | ||
40 | Model of | |
41 | -------- | |
42 | ||
43 | |Numeric Metafunction| | |
44 | ||
45 | ||
46 | Parameters | |
47 | ---------- | |
48 | ||
49 | +---------------+---------------------------+-----------------------------------------------+ | |
50 | | Parameter | Requirement | Description | | |
51 | +===============+===========================+===============================================+ | |
52 | | |T1...Tn| | |Integral Constant| | Operation's arguments. | | |
53 | +---------------+---------------------------+-----------------------------------------------+ | |
54 | ||
55 | |Note:| |numeric metafunction note| |-- end note| | |
56 | ||
57 | ||
58 | Expression semantics | |
59 | -------------------- | |
60 | ||
61 | For any |Integral Constant|\ s |c1...cn|: | |
62 | ||
63 | ||
64 | .. parsed-literal:: | |
65 | ||
66 | typedef bitxor_<c1,\ |...|\ c\ *n*\>::type r; | |
67 | ||
68 | :Return type: | |
69 | |Integral Constant|. | |
70 | ||
71 | :Semantics: | |
72 | Equivalent to | |
73 | ||
74 | .. parsed-literal:: | |
75 | ||
76 | typedef integral_c< | |
77 | typeof(c1::value ^ c2::value) | |
78 | , ( c1::value ^ c2::value ) | |
79 | > c; | |
80 | ||
81 | typedef bitxor_<c,c3,\ |...|\c\ *n*\>::type r; | |
82 | ||
83 | .. .......................................................................... | |
84 | ||
85 | .. parsed-literal:: | |
86 | ||
87 | typedef bitxor_<c1,\ |...|\ c\ *n*\> r; | |
88 | ||
89 | :Return type: | |
90 | |Integral Constant|. | |
91 | ||
92 | :Semantics: | |
93 | Equivalent to | |
94 | ||
95 | .. parsed-literal:: | |
96 | ||
97 | struct r : bitxor_<c1,\ |...|\ c\ *n*\>::type {}; | |
98 | ||
99 | ||
100 | Complexity | |
101 | ---------- | |
102 | ||
103 | Amortized constant time. | |
104 | ||
105 | ||
106 | Example | |
107 | ------- | |
108 | ||
109 | .. parsed-literal:: | |
110 | ||
111 | typedef integral_c<unsigned,0> u0; | |
112 | typedef integral_c<unsigned,1> u1; | |
113 | typedef integral_c<unsigned,2> u2; | |
114 | typedef integral_c<unsigned,8> u8; | |
115 | typedef integral_c<unsigned,0xffffffff> uffffffff; | |
116 | ||
117 | BOOST_MPL_ASSERT_RELATION( (bitxor_<u0,u0>::value), ==, 0 ); | |
118 | BOOST_MPL_ASSERT_RELATION( (bitxor_<u1,u0>::value), ==, 1 ); | |
119 | BOOST_MPL_ASSERT_RELATION( (bitxor_<u0,u1>::value), ==, 1 ); | |
120 | ||
121 | BOOST_MPL_ASSERT_RELATION( (bitxor_<u0,uffffffff>::value), ==, 0xffffffff ^ 0 ); | |
122 | BOOST_MPL_ASSERT_RELATION( (bitxor_<u1,uffffffff>::value), ==, 0xffffffff ^ 1 ); | |
123 | BOOST_MPL_ASSERT_RELATION( (bitxor_<u8,uffffffff>::value), ==, 0xffffffff ^ 8 ); | |
124 | ||
125 | ||
126 | See also | |
127 | -------- | |
128 | ||
129 | |Bitwise Operations|, |Numeric Metafunction|, |numeric_cast|, |bitand_|, |bitor_|, |shift_left| | |
130 | ||
131 | ||
132 |