Skip to content

Commit

Permalink
refactor: Remove MPL library
Browse files Browse the repository at this point in the history
This commit removes the mostly unused MPL library. The few cases in
which it was being used could be easily refactored into uses of fold
expressions, which should allow better error messages.

Depends on #3573.
  • Loading branch information
stephenswat committed Sep 24, 2024
1 parent 17b7b92 commit 6b898a6
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 672 deletions.
5 changes: 5 additions & 0 deletions Core/include/Acts/Propagator/ActorConcepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ namespace Acts {
template <typename actor_t>
concept ActorHasResult = requires { typename actor_t::result_type; };

template <typename actor_t>
struct ActorHasResultStruct {
static constexpr bool value = ActorHasResult<actor_t>;
};

template <typename actor_t, typename propagator_state_t, typename stepper_t,
typename navigator_t, typename... Args>
concept ActorHasActWithoutResult = requires(
Expand Down
32 changes: 16 additions & 16 deletions Core/include/Acts/Propagator/ActorList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@
#pragma once

#include "Acts/Propagator/detail/actor_list_implementation.hpp"
#include "Acts/Utilities/detail/MPL/all_of.hpp"
#include "Acts/Utilities/detail/MPL/has_duplicates.hpp"
#include "Acts/Utilities/detail/MPL/type_collector.hpp"

#include <boost/hana/type.hpp>
#include <boost/hana/unpack.hpp>

namespace hana = boost::hana;
#include "Acts/Utilities/TypeList.hpp"

namespace Acts {
/// @brief Extract the result type of an actor
template <typename T>
struct ActorResultTypeExtractor {
using type = T::result_type;
};

/// @brief ActorList implementation to be used with the propagator
///
/// This is the ActorList struct that is used in the propagator
/// to define a list of different actors_t that are each
/// executed during the stepping procedure
template <typename... actors_t>
requires(
detail::all_of_v<std::is_default_constructible<actors_t>::value...> &&
detail::all_of_v<std::is_copy_constructible<actors_t>::value...> &&
detail::all_of_v<std::is_move_constructible<actors_t>::value...> &&
!detail::has_duplicates_v<actors_t...>)
requires((std::is_default_constructible<actors_t>::value && ...) &&
(std::is_copy_constructible<actors_t>::value && ...) &&
(std::is_move_constructible<actors_t>::value && ...) &&
((Types::count<actors_t, TypeList<actors_t...>>::value == 1) && ...))
struct ActorList {
/// @cond
// This uses the type collector and unpacks using the `R` meta function
// template <template <typename...> class R>
template <template <typename...> class R>
using result_type = typename decltype(hana::unpack(
detail::type_collector_t<detail::result_type_extractor, actors_t...>,
hana::template_<R>))::type;
using result_type = typename Types::apply<
R, typename Types::map<ActorResultTypeExtractor,
typename Types::filter<ActorHasResultStruct,
actors_t...>::type>::type>::
type;
/// @endcond

/// Default constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#pragma once

#include "Acts/Propagator/ActorConcepts.hpp"
#include "Acts/Utilities/detail/MPL/type_collector.hpp"

#include <tuple>
#include <utility>
Expand All @@ -36,7 +35,7 @@ struct actor_caller {
if constexpr (ActorHasActWithResult<actor_t, propagator_state_t, stepper_t,
navigator_t, Args...>) {
actor.act(state, stepper, navigator,
state.template get<detail::result_type_t<actor_t>>(),
state.template get<typename actor_t::result_type>(),
std::forward<Args>(args)...);
return;
}
Expand All @@ -60,7 +59,7 @@ struct actor_caller {
stepper_t, navigator_t, Args...>) {
return actor.checkAbort(
state, stepper, navigator,
state.template get<detail::result_type_t<actor_t>>(),
state.template get<typename actor_t::result_type>(),
std::forward<Args>(args)...);
}

Expand Down
61 changes: 61 additions & 0 deletions Core/include/Acts/Utilities/TypeList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include <concepts>
#include <cstddef>
#include <type_traits>

Expand Down Expand Up @@ -93,5 +94,65 @@ template <typename L, typename N>
using push_front = typename doPushFront<N, L>::type;
/// @}

/// Filter a list of types
/// @{
template <template <typename> typename Pred, typename... Ts>
struct filter {};

template <template <typename> typename Pred>
struct filter<Pred> {
using type = TypeList<>;
};

template <typename T, typename... Ts, template <typename> typename Pred>
struct filter<Pred, T, Ts...> {
using _next_type = filter<Pred, Ts...>::type;
using type =
std::conditional_t<Pred<T>::value, push_front<_next_type, T>, _next_type>;
};
/// @}

/// Apply a typelist to a type function
/// @{
template <template <typename...> typename F, typename T>
struct apply {};

template <template <typename...> typename F, typename... Ts>
struct apply<F, TypeList<Ts...>> {
using type = F<Ts...>;
};
/// @}

/// Apply a mapping function to a type list
/// @{
template <template <typename> typename F, typename T>
struct map {};

template <template <typename> typename F, typename... Ts>
struct map<F, TypeList<Ts...>> {
using type = TypeList<typename F<Ts>::type...>;
};
/// @}

/// Count the number of times a type occurs in a type list
/// @{
template <typename T, typename L>
struct count {};

template <typename T>
struct count<T, TypeList<>> {
static constexpr std::size_t value = 0;
};

template <typename T, typename U, typename... Us>
struct count<T, TypeList<U, Us...>> {
static constexpr std::size_t value =
std::conditional_t<std::is_same_v<T, U>,
std::integral_constant<std::size_t, 1>,
std::integral_constant<std::size_t, 0>>::value +
count<T, TypeList<Us...>>::value;
};
/// @}

} // namespace Types
} // namespace Acts
8 changes: 3 additions & 5 deletions Core/include/Acts/Utilities/detail/Extendable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

#pragma once

#include "Acts/Utilities/detail/MPL/all_of.hpp"

#include <tuple>
#include <type_traits>

Expand All @@ -26,11 +24,11 @@ namespace Acts::detail {
template <typename... extensions_t>
struct Extendable {
// clang-format off
static_assert(detail::all_of_v<std::is_default_constructible<extensions_t>::value...>,
static_assert((std::is_default_constructible<extensions_t>::value && ...),
"all extensions must be default constructible");
static_assert(detail::all_of_v<std::is_copy_constructible<extensions_t>::value...>,
static_assert((std::is_copy_constructible<extensions_t>::value && ...),
"all extensions must be copy constructible");
static_assert(detail::all_of_v<std::is_move_constructible<extensions_t>::value...>,
static_assert((std::is_move_constructible<extensions_t>::value && ...),
"all extensions must be move constructible");
// clang-format on

Expand Down
29 changes: 0 additions & 29 deletions Core/include/Acts/Utilities/detail/MPL/all_of.hpp

This file was deleted.

29 changes: 0 additions & 29 deletions Core/include/Acts/Utilities/detail/MPL/any_of.hpp

This file was deleted.

61 changes: 0 additions & 61 deletions Core/include/Acts/Utilities/detail/MPL/are_sorted.hpp

This file was deleted.

45 changes: 0 additions & 45 deletions Core/include/Acts/Utilities/detail/MPL/are_within.hpp

This file was deleted.

36 changes: 0 additions & 36 deletions Core/include/Acts/Utilities/detail/MPL/at_index.hpp

This file was deleted.

Loading

0 comments on commit 6b898a6

Please sign in to comment.