kumi
v3.1.0
Exquisite Epidote
Loading...
Searching...
No Matches
◆
partition()
template<template< typename > typename Pred, concepts::product_type T>
auto kumi::partition
(
T &&
t
)
inline
nodiscard
constexpr
noexcept
Partition a product type over a predicate.
Template Parameters
Pred
Compile-time predicate
Parameters
t
Product type to process
Returns
A tuple containing the product type of all values which types satisfies
Pred
and the product type of all values which types does not satisfy
Pred
.
Helper type
namespace
kumi
{
template
<
template
<
typename
>
typename
Pred, kumi::product_type T>
struct
partition
;
template
<
template
<
typename
>
typename
Pred, kumi::product_type T>
using
partition_t =
typename
partition<Pred, T>::type
;
}
kumi::partition
constexpr auto partition(T &&t) noexcept
Partition a product type over a predicate.
Definition
partition.hpp:64
kumi
Main KUMI namespace.
Definition
algorithm.hpp:11
Computes the type returned by a call to
kumi::partition
.
Examples:
#include <kumi/kumi.hpp>
#include <type_traits>
#include <iostream>
int
main()
{
int
a = 4;
double
b = 3.1415;
float
c = 0.01f;
auto
original =
kumi::tuple
{a,&a,b,&b,c,&c,
'z'
,
nullptr
};
std::cout << original <<
"\n"
;
std::cout <<
"Pointers first: "
<<
kumi::partition<std::is_pointer>
(original) <<
"\n"
;
std::cout <<
"Real first: "
<<
kumi::partition<std::is_floating_point>
(original) <<
"\n"
;
std::cout <<
"nullptr first: "
<<
kumi::partition<std::is_null_pointer>
(original) <<
"\n"
;
}
kumi::tuple
Fixed-size collection of heterogeneous values.
Definition
tuple.hpp:29
#include <kumi/kumi.hpp>
#include <type_traits>
#include <iostream>
int
main()
{
using namespace
kumi::literals;
int
a = 4;
double
b = 3.1415;
float
c = 0.01f;
auto
original =
kumi::record
{
"a"
_id = a,
"b"
_id = &a,
"c"
_id = b,
"d"
_id = &b,
"e"
_id = c,
"f"
_id = &c,
"g"
_id =
'z'
,
"h"
_id =
nullptr
};
std::cout << original <<
"\n"
;
std::cout <<
"Pointers first: "
<<
kumi::partition<std::is_pointer>
(original) <<
"\n"
;
std::cout <<
"Real first: "
<<
kumi::partition<std::is_floating_point>
(original) <<
"\n"
;
std::cout <<
"nullptr first: "
<<
kumi::partition<std::is_null_pointer>
(original) <<
"\n"
;
}
kumi::record
Fixed-size collection of heterogeneous fields necessarily named, names are unique.
Definition
record.hpp:29
kumi