5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_LIST_REMOVE_DUPLICATES_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_LIST_REMOVE_DUPLICATES_HPP_
16#include "arene/base/detail/dynamic_extent.hpp"
18#include "arene/base/stdlib_choice/cstddef.hpp"
19#include "arene/base/stdlib_choice/ignore.hpp"
20#include "arene/base/stdlib_choice/integer_sequence.hpp"
21#include "arene/base/stdlib_choice/not_equal_to.hpp"
34namespace remove_duplicates_detail {
39struct remove_duplicates_impl;
61constexpr auto count(Range
const& range,
std::size_t value)
67 for (
auto const& elem : range) {
87template <std::
size_t N>
97 value_type values[N]{};
103 constexpr auto begin() noexcept -> value_type* {
return values; }
106 constexpr auto begin() const noexcept -> value_type const* {
return values; }
111 constexpr auto end() noexcept -> value_type* {
return begin() + N; }
114 constexpr auto end() const noexcept -> value_type const* {
return begin() + N; }
136 -> index_array<
sizeof...(Ts)>
155extern constexpr auto masked_indices_of =
nullptr;
161template <
template <
class...>
class List,
class... Ts>
162extern constexpr auto masked_indices_of<List<Ts...>> =
169extern constexpr auto unique_count_v = type_lists::size_v<List> - count(masked_indices_of<List>, dynamic_extent);
183template <
class... Ts>
184constexpr auto unique_indices_impl() -> index_array<unique_count_v<Ts...>>
186 auto filtered = index_array<unique_count_v<Ts...>>{};
188 masked_indices_of<Ts...>.
begin(),
189 masked_indices_of<Ts...>.
end(),
191 arene::base::bind_back(std::not_equal_to<>{}, dynamic_extent)
200template <
class... Ts>
201extern constexpr auto unique_indices = unique_indices_impl<Ts...>();
210template <
template <
class...>
class List,
class... Ts,
std::size_t... Js>
215 unique_indices<List<Ts...>>.begin()[Js]>...>;
225template <
template <
class...>
class List,
class T0,
class... Tn>
226auto remove_duplicates_from(type_identity<List<T0, Tn...>>)
228 remove_duplicates_from_impl<List, T0, Tn...>(
239template <
template <
class...>
class List>
240auto remove_duplicates_from(type_identity<List<>>) -> List<>;
246template <
template <
class...>
class List,
class... Ts>
247struct remove_duplicates_impl<List<Ts...>> {
249 sizeof...(Ts) != dynamic_extent,
250 "cannot handle 'std::size_t(-1)' number of types"
254 using type =
decltype(remove_duplicates_from(type_identity<List<Ts...>>{}));
268using remove_duplicates = arene::base::type_lists::remove_duplicates_detail::remove_duplicates_impl<L0>;
Definition apply_all.hpp:14
typename remove_duplicates< L0 >::type remove_duplicates_t
Filter a type-list to remove duplicates of elements.
Definition remove_duplicates.hpp:277
arene::base::type_lists::remove_duplicates_detail::remove_duplicates_impl< L0 > remove_duplicates
Filter a type-list to remove duplicates of elements.
Definition remove_duplicates.hpp:268
Definition accumulate.hpp:37
constexpr auto last_index_of_v
Template meta-function for querying the last 0-based index of 'T' within a list of types,...
constexpr auto copy_if(InputIterator first, InputIterator last, OutputIterator output, Predicate pred) noexcept(noexcept(*output++) &&//CODEQLFP(EXP52-CPP) noexcept(++first) &&//CODEQLFP(EXP52-CPP) CODEQLFP(A5-2-6) CODEQLFP(M5-14-1) noexcept(*first) &&//CODEQLFP(EXP52-CPP) CODEQLFP(A5-2-6) CODEQLFP(M5-14-1) noexcept(first !=last) &&//CODEQLFP(A5-2-6) std::is_nothrow_assignable<, typename std::iterator_traits< InputIterator >::reference >::value &&//CODEQLFP(A5-1-1) CODEQLFP(M5-3-1) base::is_nothrow_invocable_v<//Predicate &, typename std::iterator_traits< InputIterator >::value_type >) -> OutputIterator
Copies the elements in the range, defined by [first, last), to another range beginning at output....
Definition copy_if.hpp:45
Definition accumulate.hpp:36
make_integer_sequence< size_t, Size > make_index_sequence
A helper alias template for make_integer_sequence<size_t, Size>
Definition integer_sequence.hpp:224
integer_sequence< size_t, Ints... > index_sequence
A helper alias template for integer_sequence<size_t, Ints>
Definition integer_sequence.hpp:218
::size_t size_t
A type suitable for holding the size of an object.
Definition cstddef.hpp:29
constexpr auto end(Element(&array)[Size]) noexcept -> Element *
Obtain a pointer to the one-past-the-end element of the array.
Definition end.hpp:28
static constexpr auto const & ignore
An object to which anything can be assigned, which ignores the assigned value.
Definition ignore.hpp:72
constexpr auto begin(Element(&array)[Size]) noexcept -> Element *
Obtain a pointer to the first element of the array.
Definition begin.hpp:28
make_index_sequence< sizeof...(Types)> index_sequence_for
A helper alias template convert any type parameter pack into an index sequence of the same length.
Definition integer_sequence.hpp:230