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

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

Variables

constexpr remove_t kumi::remove {}

Detailed Description

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

Variable Documentation

◆ remove

remove_t kumi::remove {}
inlineconstexprnodiscardnoexcept

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 B or E is greater than kumi::size_v<T>, or if S is 0. It returns every element of t when E is not greater than B.

Header file

#include <kumi/kumi.hpp>

Call Signature

namespace kumi
{
template<concepts::product_type T, std::size_t B, std::size_t E, std::size_t S>
constexpr auto remove(T && t, kumi::index_t<B>, kumi::index_t<E>, kumi::index_t<S>) noexcept; // 1
template<concepts::product_type T, std::size_t B, std::size_t E>
constexpr auto remove(T && t, kumi::index_t<B>, kumi::index_t<E>) noexcept; // 2
template<concepts::product_type T, std::size_t B>
constexpr auto remove(T && t, kumi::index_t<B>) noexcept; // 3
}
constexpr remove_t remove
Definition extract.hpp:239
Main KUMI namespace.
Definition algorithm.hpp:11
Integral constant type.
Definition ct_helpers.hpp:32

Template Parameters

  • B: Compile-time index of the first element to remove
  • E: Compile-time index past the last element to remove
  • S: Compile-time distance between two removed elements

Parameters

  • t: Product Type to remove elements from

Return value

  • 1. A new product type containing the elements of t except those at the indexes B, B + S, B + 2 * S, and so on, lower than E.
  • 2. A new product type containing the elements of t except those from the index B to the index E, E excluded.
  • 3. A new product type containing the elements of t before the index B.

Helper type

template<kumi::concepts::product_type T, std::size_t... I>
requires((1 <= sizeof...(I)) && (sizeof...(I) <= 3))
using remove_t = decltype(kumi::remove(kumi::declval<T>(), kumi::index_t<I>{}...));
template<kumi::concepts::product_type T, std::size_t... I>
requires((1 <= sizeof...(I)) && (sizeof...(I) <= 3))
struct remove
{
using type = kumi::result::remove_t<T, I...>;
};

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';
    }
    Fixed-size collection of heterogeneous values.
    Definition tuple.hpp:35
  • 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 fields with distinct labels.
    Definition record.hpp:36