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_
15#include "arene/base/algorithm/copy_if.hpp"
16#include "arene/base/detail/dynamic_extent.hpp"
17#include "arene/base/functional/bind_back.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"
22#include "arene/base/type_list/at.hpp"
23#include "arene/base/type_list/size.hpp"
24#include "arene/base/type_traits/index_of.hpp"
25#include "arene/base/type_traits/type_identity.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>
91 using value_type = std::size_t;
97 value_type values[N]{};
102 constexpr auto begin()
noexcept -> value_type* {
return values; }
105 constexpr auto begin()
const noexcept -> value_type
const* {
return values; }
110 constexpr auto end()
noexcept -> value_type* {
return begin() + N; }
113 constexpr auto end()
const noexcept -> value_type
const* {
return begin() + N; }
132template <
class... Ts, std::size_t... Is>
133constexpr auto masked_indices_of_impl(std::index_sequence<Is...>)
134 -> index_array<
sizeof...(Ts)>
139 ((Is == arene::base::last_index_of_v<Ts, Ts...>)
153extern constexpr auto masked_indices_of =
nullptr;
159template <
template <
class...>
class List,
class... Ts>
160extern constexpr auto masked_indices_of<List<Ts...>> =
161 masked_indices_of_impl<Ts...>(std::index_sequence_for<Ts...>{});
167extern constexpr auto unique_count_v = type_lists::size_v<List> - count(masked_indices_of<List>, dynamic_extent);
181template <
class... Ts>
182constexpr auto unique_indices_impl() -> index_array<unique_count_v<Ts...>>
184 auto filtered = index_array<unique_count_v<Ts...>>{};
185 std::ignore = arene::base::copy_if(
186 masked_indices_of<Ts...>.begin(),
187 masked_indices_of<Ts...>.end(),
189 arene::base::bind_back(std::not_equal_to<>{}, dynamic_extent)
198template <
class... Ts>
199extern constexpr auto unique_indices = unique_indices_impl<Ts...>();
208template <
template <
class...>
class List,
class... Ts, std::size_t... Js>
209auto remove_duplicates_from_impl(std::index_sequence<Js...>)
213 unique_indices<List<Ts...>>.begin()[Js]>...>;
223template <
template <
class...>
class List,
class T0,
class... Tn>
224auto remove_duplicates_from(type_identity<List<T0, Tn...>>)
226 remove_duplicates_from_impl<List, T0, Tn...>(
227 std::make_index_sequence<unique_count_v<List<T0, Tn...>>>{}
237template <
template <
class...>
class List>
238auto remove_duplicates_from(type_identity<List<>>) -> List<>;
244template <
template <
class...>
class List,
class... Ts>
245struct remove_duplicates_impl<List<Ts...>> {
247 sizeof...(Ts) != dynamic_extent,
248 "cannot handle 'std::size_t(-1)' number of types"
252 using type =
decltype(remove_duplicates_from(type_identity<List<Ts...>>{}));
Definition apply_all.hpp:14
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10