KUMI v4.0.0
Flawless Fluorite
Loading...
Searching...
No Matches

◆ remove

remove_t kumi::remove {}
inlineconstexprnodiscardnoexcept

Callable object removing a sub product type from a product type.

On record types, this function operates on elements as if they were ordered. The considered order is the order of declaration.

Note
This function will issue a compile time error if I0 and I1 do not verify that 0 <= I0 <= I1 <= size_v<T>.

Header file

#include <kumi/algorithm/extract.hpp>

Call Signature

template<product_type T, std::size_t I0, std::size_t I1>
constexpr auto remove(T && t, kumi::index_t<I0>, kumi::index_t<I1>) noexcept; // 1
constexpr remove_t remove
Callable object removing a sub product type from a product type.
Definition extract.hpp:203
Integral constant type.
Definition ct_helpers.hpp:32
template<product_type T, std::size_t I0>
constexpr auto remove(T && t, kumi::index_t<I0>) noexcept; // 2

Parameters

  • t: Product Type to remove elements from
  • i0: Compile-time index of the first element to extract
  • i1: Compile-time index past the last element to extract

Return value

  • 1. A new product type containing the elements of t without the range of elements from I0 to I1.
  • 2. A new product type containing the elements of t without the range of elements from I0 to size_v<T>.

Helper type

template<kumi::concepts::product_type T, std::size_t I0, std::size_t I1 = std::size_t(-1)> struct remove
{
using type = decltype(kumi::remove(std::declval<T>(), kumi::index_t<I0>{}, kumi::index_t<I1>{}));
};
template<kumi::concepts::product_type T, std::size_t I0> struct remove<T, I0>
{
using type = decltype(kumi::remove(std::declval<T>(), kumi::index_t<I0>{}));
};
template<kumi::concepts::product_type T, std::size_t I0, std::size_t I1 = std::size_t(-1)>
using remove_t = typename kumi::result::remove<T, I0, I1>::type;

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

Examples

Tuple

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
kumi::tuple a = { 1, 2.3, 4.5f,'6',"7", short{89} };
auto last = kumi::remove(a,0_c,1_c);
auto mid = kumi::remove(a,1_c,3_c);
auto head = kumi::remove(a,kumi::index<3>);
std::cout << a << " => " << head << ' ' << mid << ' ' << last << '\n';
}
constexpr kumi::index_t< N > const index
Inline integral constant value for kumi::index_t.
Definition ct_helpers.hpp:49
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:33

Record

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
kumi::record a = { "a"_id = 1, "b"_id = 2.3, "c"_id = 4.5f, "d"_id = '6'
, "e"_id = "7", "f"_id = short{89} };
auto last = kumi::remove(a,0_c,1_c);
auto mid = kumi::remove(a,1_c,3_c);
auto head = kumi::remove(a,kumi::index<3>);
std::cout << a << " => " << head << ' ' << mid << ' ' << last << '\n';
}
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36