KUMI v5.0.0
Gorgeous Garnet
Loading...
Searching...
No Matches

Callable object computing the bitwise AND of all elements. More...

Variables

constexpr bit_and_t kumi::bit_and {}

Detailed Description

Callable object computing the bitwise AND of all elements.

Variable Documentation

◆ bit_and

bit_and_t kumi::bit_and {}
inlineconstexprnodiscard

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

Note
For associative operations, this produces the same result as a left or right fold, but has a different intermediate evaluation order.

inline constexpr

Header file

#include <kumi/kumi.hpp>

Call Signature

namespace kumi
{
template<concepts::product_type T>
constexpr auto bit_and(T && t);
template<concepts::product_type T, typename V>
constexpr auto bit_and(T && t, V init);
}
constexpr bit_and_t bit_and
Definition reduce.hpp:522
Main KUMI namespace.
Definition algorithm.hpp:11

Parameters

  • t: Product Type to operate on
  • init: Optional initial value of the reduction.

Return value

The result of the computation of `get<0>(t) & ... & get<N-1>(t) & init`

Helper type

namespace kumi::result
{
template<product_type T, typename Value> struct bit_and;
template<product_type T, typename Value>
using bit_and_t = typename bit_and<T,Value>::type;
}

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:35
  • 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 fields with distinct labels.
    Definition record.hpp:36