Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
drop.hpp
Go to the documentation of this file.
1// Copyright 2026, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_LIST_DROP_HPP_
5#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_LIST_DROP_HPP_
6
7#include "arene/base/constraints/constraints.hpp"
8#include "arene/base/stdlib_choice/cstddef.hpp"
9#include "arene/base/stdlib_choice/declval.hpp"
10#include "arene/base/stdlib_choice/enable_if.hpp"
11#include "arene/base/stdlib_choice/integer_sequence.hpp"
12#include "arene/base/type_list/at.hpp"
13
14namespace arene {
15namespace base {
16namespace type_lists {
17
18namespace drop_detail {
19
20// parasoft-begin-suppress CERT_C-EXP37-a "False positive: The rule does not mention naming all parameters"
21/// @brief helper removing the first @c Count types
22/// @tparam Count number of types to remove
23/// @tparam Is indices
24/// @tparam List type list type
25/// @tparam Ts types
26/// @return @c List after removing the first @c Count types from @c Ts...
27template <std::size_t Count, std::size_t... Is, template <class...> class List, class... Ts>
28auto drop_impl(std::index_sequence<Is...>, List<Ts...>) -> List<at_t<List<Ts...>, Count + Is>...>;
29// parasoft-end-suppress CERT_C-EXP37-a
30
31/// @brief implementation helper for drop
32/// @tparam List type list
33/// @tparam Count number of types to drop
34///
35/// Undefined primary template.
36template <class List, std::size_t Count, class = constraints<>>
37class drop;
38
39/// @brief implementation helper for drop
40/// @tparam List type list type
41/// @tparam Ts types
42/// @tparam Count number of types to drop
43///
44/// Specialization for @c Count less than the size of @c List<Ts...>
45template <template <class...> class List, class... Ts, std::size_t Count>
46class drop<List<Ts...>, Count, constraints<std::enable_if_t<(Count < sizeof...(Ts))>>> {
47 public:
48 /// @brief resulting type list
49 using type =
50 decltype(drop_impl<Count>(std::make_index_sequence<sizeof...(Ts) - Count>{}, std::declval<List<Ts...>>()));
51};
52
53/// @brief implementation helper for drop
54/// @tparam List type list type
55/// @tparam Ts types
56/// @tparam Count number of types to drop
57///
58/// Specialization for @c Count greater than or equal to the size of @c List<Ts...>
59template <template <class...> class List, class... Ts, std::size_t Count>
60class drop<List<Ts...>, Count, constraints<std::enable_if_t<(Count >= sizeof...(Ts))>>> {
61 public:
62 /// @brief resulting type list
63 using type = List<>;
64};
65
66} // namespace drop_detail
67
68/// @brief drops types from the front of a type list
69/// @tparam List type-list-like
70/// @tparam Count number of types to drop
71///
72/// For any type-list-like @c List, provides the member typedef @c type which is
73/// the same as @c List but with the first @c Count types omitted. If @c Count
74/// exceeds the number of types in @c List, @c type specifies an "empty"
75/// type-list.
76///
77/// Usage:
78/// @snippet docs/examples/type_list_examples.cpp drop_example
79///
80///
81template <class List, std::size_t Count>
83
84/// @brief drops types from the front of a type list
85/// @tparam List type-list-like
86/// @tparam Count number of types to drop
87/// @copydoc drop
88template <class List, std::size_t Count>
89using drop_t = typename drop<List, Count>::type;
90
91} // namespace type_lists
92} // namespace base
93} // namespace arene
94
95#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_LIST_DROP_HPP_
Definition apply_all.hpp:14
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10