KUMI v3.1.0
Exquisite Epidote
Loading...
Searching...
No Matches

◆ bit_and() [1/2]

template<concepts::product_type T>
auto kumi::bit_and ( T && t)
inlinenodiscardconstexpr

Computes the bitwise AND of all elements.

On record types, this function operates on the underlying values, not on the fields themselves.

Parameters
tProduct type to operate on.
Returns
The value of get<0>(t) & ... & get<N-1>(t).

Helper type

namespace kumi::result
{
template<product_type T> struct bit_and;
template<product_type T>
using bit_and_t = typename bit_and<T>::type;
}
constexpr auto bit_and(T &&t, Value init)
Computes the bitwise AND of all elements.
Definition reduce.hpp:410

Computes the return type of a call to kumi::bit_and

Examples:

Tuple:

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
auto t = kumi::tuple{14,short{7}, 255ULL};
std::cout << kumi::bit_and(t, 65535) << "\n";
std::cout << kumi::bit_and(t) << "\n";
}
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:33

Record:

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
auto t = kumi::record{"a"_id = 14,"b"_id = short{7}, "c"_id = 255ULL};
std::cout << kumi::bit_and(t, 65535) << "\n";
std::cout << kumi::bit_and(t) << "\n";
}
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36