7 #include "arg_router/traits.hpp"
9 #include <boost/mp11/bind.hpp>
12 #include <string_view>
28 template <
template <
typename...>
typename T,
typename Tuple>
37 constexpr
static std::size_t
value = boost::mp11::mp_find_if<Tuple, fn>::value;
45 template <
template <
typename...>
typename T,
typename Tuple>
60 template <
template <
typename...>
typename T,
typename Tuple>
67 constexpr
static std::size_t value = boost::mp11::mp_count_if<Tuple, fn>::value;
75 template <
template <
typename...>
typename T,
typename Tuple>
84 template <
typename T,
typename Tuple>
91 constexpr
static std::size_t value = boost::mp11::mp_count_if<Tuple, fn>::value;
99 template <
typename T,
typename Tuple>
112 template <
template <
typename...>
typename T,
typename Tuple>
115 constexpr
static bool value = find_specialisation_v<T, Tuple> < std::tuple_size_v<Tuple>;
123 template <
template <
typename...>
typename T,
typename Tuple>
134 template <
typename First,
typename Second>
137 static_assert((std::tuple_size_v<First> == std::tuple_size_v<Second>),
138 "First and Second tuples must contain the same number of elements");
140 template <std::size_t... N>
141 [[nodiscard]] constexpr
static auto zip_impl_t(
142 std::integer_sequence<std::size_t, N...>) noexcept
144 std::pair<std::tuple_element_t<N, First>, std::tuple_element_t<N, Second>>...>;
149 decltype(zip_impl_t(std::declval<std::make_index_sequence<std::tuple_size_v<First>>>()));
157 template <
typename First,
typename Second>
164 template <
typename T>
167 using first_type = boost::mp11::mp_transform<boost::mp11::mp_first, T>;
170 using second_type = boost::mp11::mp_transform<boost::mp11::mp_second, T>;
175 template <
typename U,
typename... I>
176 [[nodiscard]] constexpr
auto tuple_filter_and_construct_impl(
178 [[maybe_unused]] std::tuple<I...> Is) noexcept
180 return std::tuple{std::get<I::value>(std::forward<U>(input))...};
195 template <
template <
typename...>
typename Fn,
typename U>
205 boost::mp11::mp_bind<Fn, boost::mp11::mp_bind<boost::mp11::mp_second, boost::mp11::_1>>;
206 using filtered = boost::mp11::mp_filter_q<wrapped_fn, zipped>;
214 template <
template <
typename...>
typename Tuple,
218 [[nodiscard]] constexpr
auto tuple_push_back_impl(
219 Tuple<Args...> tuple,
221 [[maybe_unused]] std::integer_sequence<std::size_t, I...> Is) noexcept
223 return Tuple{std::move(std::get<I>(tuple))..., std::move(insert)};
227 template <
template <
typename...>
typename Tuple,
typename Insert>
228 [[nodiscard]] constexpr
auto tuple_push_back_impl(
229 [[maybe_unused]] Tuple<> t,
231 [[maybe_unused]] std::integer_sequence<std::size_t> Is) noexcept
233 return Tuple{std::move(insert)};
245 template <
typename Tuple,
typename Insert>
249 return detail::tuple_push_back_impl(std::move(tuple),
251 std::make_index_sequence<std::tuple_size_v<Tuple>>{});
256 template <std::size_t Count,
typename U, std::size_t... I>
257 [[nodiscard]] constexpr
auto tuple_drop_impl(
260 [[maybe_unused]] std::integer_sequence<std::size_t, I...>) noexcept
262 return std::tuple{std::get<I + Count>(std::forward<U>(input))...};
271 template <std::
size_t Count,
typename Tuple>
274 return detail::tuple_drop_impl<Count>(
275 std::forward<Tuple>(input),
276 std::make_index_sequence<std::tuple_size_v<Tuple> - Count>{});
287 template <std::size_t I,
typename... T>
290 static_assert(I <
sizeof...(pack),
"Index out of bounds for pack");
291 return std::get<I>(std::tuple{std::cref(pack)...}).get();
constexpr static std::size_t value
decltype(zip_impl_t(std::declval< std::make_index_sequence< std::tuple_size_v< First > >>())) type
constexpr auto tuple_drop(Tuple &&input)
constexpr auto count_despecialised_v
constexpr auto count_specialisation_v
constexpr auto find_specialisation_v
constexpr auto has_specialisation_v
constexpr auto & pack_element(const T &... pack) noexcept
typename zip< First, Second >::type zip_t
constexpr auto tuple_push_back(Tuple tuple, Insert insert) noexcept
constexpr auto tuple_filter_and_construct(U &&input) noexcept
constexpr static bool value
boost::mp11::mp_transform< boost::mp11::mp_second, T > second_type
boost::mp11::mp_transform< boost::mp11::mp_first, T > first_type