1 #ifndef FUNCTIONS_BIT_H
2 #define FUNCTIONS_BIT_H
6 #include "functions_type.h"
19 #define iand(a,b) ( (a) & (b) )
26 #define ior(a,b) ( (a) | (b) )
33 #define inor(a,b) ( ~( (a) | (b) ) )
40 #define ixor(a,b) ( (a) ^ (b) ) )
45 #define inot(a) ( 256 - (~(a)) )
47 namespace functions_bit {
53 template<
typename T> requires functions_type::isIntegerType<T>
54 inline static T& bitSet(T& a,
const tUCInt& p) {
60 template<
typename T> requires functions_type::isIntegerType<T>
61 inline static T& bitClear(T& a,
const tUCInt& p) {
66 template<
typename T> requires functions_type::isIntegerType<T>
67 inline static T& bitFlip(T& a,
const tUCInt& p) {
73 template<
typename T> requires functions_type::isIntegerType<T>
74 inline static tBoolean bitGet(
const T& a,
const tUCInt& p) {
75 return (!!(a & (1ULL<<p)));
80 template<
typename T> requires functions_type::isIntegerType<T>
81 inline static T& bitMaskSet(T& x,
const T& mask) {
87 template<
typename T> requires functions_type::isIntegerType<T>
88 inline static T& bitMaskClear(T& x,
const T& mask) {
94 template<
typename T> requires functions_type::isIntegerType<T>
95 inline static T& bitMaskFlip(T& x,
const T& mask) {
101 template<
typename T> requires functions_type::isIntegerType<T>
102 inline static tBoolean bitMaskCheckAll(
const T& x,
const T& mask) {
103 return (!(~(x) & (mask)));
108 template<
typename T> requires functions_type::isIntegerType<T>
109 inline static tBoolean bitMaskCheckAny(
const T& x,
const T& mask) {
110 return ((x) & (mask));