Skip to content

Commit

Permalink
Merge branch 'main' into houghtester
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Aug 30, 2024
2 parents 779159b + 5084be5 commit cb784eb
Show file tree
Hide file tree
Showing 35 changed files with 822 additions and 743 deletions.
18 changes: 6 additions & 12 deletions Core/include/Acts/EventData/MultiTrajectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "Acts/Utilities/HashedString.hpp"
#include "Acts/Utilities/Helpers.hpp"
#include "Acts/Utilities/ThrowAssert.hpp"
#include "Acts/Utilities/TypeTraits.hpp"

#include <bitset>
#include <cstddef>
Expand Down Expand Up @@ -116,12 +115,9 @@ class TrackStateRange {

// implement track state visitor concept
template <typename T, typename TS>
using call_operator_t = decltype(std::declval<T>()(std::declval<TS>()));

template <typename T, typename TS>
constexpr bool VisitorConcept = Concepts ::require<
Concepts ::either<Concepts ::identical_to<bool, call_operator_t, T, TS>,
Concepts ::identical_to<void, call_operator_t, T, TS>>>;
concept VisitorConcept = requires(T& t, TS& ts) {
{ t(ts) } -> Concepts::same_as_any_of<void, bool>;
};

} // namespace detail_lt

Expand Down Expand Up @@ -269,7 +265,8 @@ class MultiTrajectory {
/// @param iendpoint index of the last state
/// @param callable non-modifying functor to be called with each point
template <typename F>
void visitBackwards(IndexType iendpoint, F&& callable) const;
void visitBackwards(IndexType iendpoint, F&& callable) const
requires detail_lt::VisitorConcept<F, ConstTrackStateProxy>;

/// Apply a function to all previous states starting at a given endpoint.
///
Expand All @@ -281,11 +278,8 @@ class MultiTrajectory {
/// @note Only available if the MultiTrajectory is not read-only
template <typename F>
void applyBackwards(IndexType iendpoint, F&& callable)
requires(!ReadOnly)
requires(!ReadOnly) && detail_lt::VisitorConcept<F, TrackStateProxy>
{
static_assert(detail_lt::VisitorConcept<F, TrackStateProxy>,
"Callable needs to satisfy VisitorConcept");

if (iendpoint == MultiTrajectoryTraits::kInvalid) {
throw std::runtime_error(
"Cannot apply backwards with kInvalid as endpoint");
Expand Down
9 changes: 3 additions & 6 deletions Core/include/Acts/EventData/MultiTrajectory.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include "Acts/Utilities/AlgebraHelpers.hpp"
#include "Acts/Utilities/TypeTraits.hpp"

#include <bitset>
#include <cstdint>
Expand All @@ -20,11 +19,9 @@ namespace Acts {

template <typename D>
template <typename F>
void MultiTrajectory<D>::visitBackwards(IndexType iendpoint,
F&& callable) const {
static_assert(detail_lt::VisitorConcept<F, ConstTrackStateProxy>,
"Callable needs to satisfy VisitorConcept");

void MultiTrajectory<D>::visitBackwards(IndexType iendpoint, F&& callable) const
requires detail_lt::VisitorConcept<F, ConstTrackStateProxy>
{
if (iendpoint == MultiTrajectoryTraits::kInvalid) {
throw std::runtime_error(
"Cannot visit backwards with kInvalid as endpoint");
Expand Down
1 change: 0 additions & 1 deletion Core/include/Acts/EventData/SourceLink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "Acts/Geometry/GeometryIdentifier.hpp"
#include "Acts/Utilities/Any.hpp"
#include "Acts/Utilities/Delegate.hpp"
#include "Acts/Utilities/TypeTraits.hpp"

#include <cassert>
#include <concepts>
Expand Down
1 change: 0 additions & 1 deletion Core/include/Acts/EventData/TrackParametersConcept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Utilities/TypeTraits.hpp"

#include <concepts>
#include <optional>
Expand Down
1 change: 0 additions & 1 deletion Core/include/Acts/Propagator/StepperConcept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "Acts/Utilities/Concepts.hpp"
#include "Acts/Utilities/Intersection.hpp"
#include "Acts/Utilities/Logger.hpp"
#include "Acts/Utilities/TypeTraits.hpp"

namespace Acts {
namespace Concepts {
Expand Down
1 change: 0 additions & 1 deletion Core/include/Acts/TrackFinding/MeasurementSelector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "Acts/TrackFinding/CombinatorialKalmanFilterError.hpp"
#include "Acts/Utilities/Logger.hpp"
#include "Acts/Utilities/Result.hpp"
#include "Acts/Utilities/TypeTraits.hpp"

#include <cassert>
#include <cstddef>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "Acts/Utilities/CalibrationContext.hpp"
#include "Acts/Utilities/Logger.hpp"
#include "Acts/Utilities/Result.hpp"
#include "Acts/Utilities/TypeTraits.hpp"

namespace Acts::detail {

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

#include <concepts>
#include <functional>
#include <type_traits>

namespace Acts::Concepts {
Expand All @@ -30,4 +31,11 @@ concept arithmetic = std::integral<T> || std::floating_point<T>;
/// same type.
template <typename T1, typename T2>
concept decayed_same_as = std::same_as<std::decay_t<T1>, std::decay_t<T2> >;

/// @brief Concept that is satisfied iff type T is callable with arguments
/// Args... and returns type U
template <auto Callable, typename U, typename... Args>
concept invocable_and_returns = requires(Args... args) {
{ std::invoke(Callable, args...) } -> std::same_as<U>;
};
} // namespace Acts::Concepts
16 changes: 6 additions & 10 deletions Core/include/Acts/Utilities/Delegate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

#include "Acts/Utilities/TypeTraits.hpp"
#include "Acts/Utilities/Concepts.hpp"

#include <cassert>
#include <functional>
Expand Down Expand Up @@ -161,8 +161,7 @@ class Delegate<R(Args...), H, O> {
m_payload.payload = nullptr;

static_assert(
Concepts::is_detected<isSignatureCompatible, function_ptr_type,
decltype(Callable)>::value,
Concepts::invocable_and_returns<Callable, return_type, Args &&...>,
"Callable given does not correspond exactly to required call "
"signature");

Expand Down Expand Up @@ -213,10 +212,8 @@ class Delegate<R(Args...), H, O> {
void connect(const Type *instance)
requires(kOwnership == DelegateType::NonOwning)
{
using member_ptr_type = return_type (Type::*)(Args...) const;

static_assert(Concepts::is_detected<isSignatureCompatible, member_ptr_type,
decltype(Callable)>::value,
static_assert(Concepts::invocable_and_returns<Callable, return_type, Type,
Args &&...>,
"Callable given does not correspond exactly to required call "
"signature");

Expand All @@ -239,9 +236,8 @@ class Delegate<R(Args...), H, O> {
void connect(std::unique_ptr<const Type> instance)
requires(kOwnership == DelegateType::Owning)
{
using member_ptr_type = return_type (Type::*)(Args &&...) const;
static_assert(Concepts::is_detected<isSignatureCompatible, member_ptr_type,
decltype(Callable)>::value,
static_assert(Concepts::invocable_and_returns<Callable, return_type, Type,
Args &&...>,
"Callable given does not correspond exactly to required call "
"signature");

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

#pragma once

#include "Acts/Utilities/TypeTraits.hpp"

#include <optional>
#include <string_view>
#include <variant>
Expand Down
Loading

0 comments on commit cb784eb

Please sign in to comment.