From 362bfa105914fc286220f042129da3d33d69ac09 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Fri, 6 Sep 2024 16:41:57 +0200 Subject: [PATCH 1/2] remove identity relic --- Core/include/Acts/Utilities/Identity.hpp | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/Core/include/Acts/Utilities/Identity.hpp b/Core/include/Acts/Utilities/Identity.hpp index 2d5c759b595..0fbaa5bf80a 100644 --- a/Core/include/Acts/Utilities/Identity.hpp +++ b/Core/include/Acts/Utilities/Identity.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021 CERN for the benefit of the Acts project +// Copyright (C) 2021-2024 CERN for the benefit of the Acts project // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -8,29 +8,8 @@ #pragma once -#if __cplusplus >= 202002L - #include namespace Acts { using Identity = std::identity; -} - -#else - -#include - -namespace Acts { - -/// @brief Function object which maps a value to itself by perfect forwarding -/// This is a backport of C++20's std::identity -struct Identity { - template - constexpr auto operator()(T &&v) const { - return std::forward(v); - } -}; - } // namespace Acts - -#endif From a6b52a60811408d7cada2c4ba7b7c0e17d88108e Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Fri, 6 Sep 2024 17:12:00 +0200 Subject: [PATCH 2/2] clean removal --- .../TrackFitting/detail/GsfComponentMerging.hpp | 5 ++--- Core/include/Acts/Utilities/Identity.hpp | 15 --------------- .../TrackFitting/GsfComponentMergingTests.cpp | 7 +++---- 3 files changed, 5 insertions(+), 22 deletions(-) delete mode 100644 Core/include/Acts/Utilities/Identity.hpp diff --git a/Core/include/Acts/TrackFitting/detail/GsfComponentMerging.hpp b/Core/include/Acts/TrackFitting/detail/GsfComponentMerging.hpp index cf5bc4bf1b0..8881bf8a298 100644 --- a/Core/include/Acts/TrackFitting/detail/GsfComponentMerging.hpp +++ b/Core/include/Acts/TrackFitting/detail/GsfComponentMerging.hpp @@ -12,7 +12,6 @@ #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Surfaces/CylinderSurface.hpp" #include "Acts/TrackFitting/GsfOptions.hpp" -#include "Acts/Utilities/Identity.hpp" #include "Acts/Utilities/detail/periodic.hpp" #include @@ -123,7 +122,7 @@ auto gaussianMixtureCov(const components_t components, /// std::tuple< weight, mean, std::optional< cov > > /// @tparam angle_desc_t A angle description object which defines the cyclic /// angles in the bound parameters -template ::Desc> auto gaussianMixtureMeanCov(const components_t components, projector_t &&projector = projector_t{}, @@ -212,7 +211,7 @@ auto gaussianMixtureMeanCov(const components_t components, /// like a std::tuple< double, BoundVector, BoundMatrix > /// /// @return parameters and covariance as std::tuple< BoundVector, BoundMatrix > -template +template auto mergeGaussianMixture(const mixture_t &mixture, const Surface &surface, ComponentMergeMethod method, projector_t &&projector = projector_t{}) { diff --git a/Core/include/Acts/Utilities/Identity.hpp b/Core/include/Acts/Utilities/Identity.hpp deleted file mode 100644 index 0fbaa5bf80a..00000000000 --- a/Core/include/Acts/Utilities/Identity.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2021-2024 CERN for the benefit of the Acts project -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#pragma once - -#include - -namespace Acts { -using Identity = std::identity; -} // namespace Acts diff --git a/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp b/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp index f547ea89503..39959dfa0de 100644 --- a/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp @@ -22,7 +22,6 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Surfaces/SurfaceBounds.hpp" #include "Acts/TrackFitting/detail/GsfComponentMerging.hpp" -#include "Acts/Utilities/Identity.hpp" #include "Acts/Utilities/Intersection.hpp" #include "Acts/Utilities/Result.hpp" #include "Acts/Utilities/detail/periodic.hpp" @@ -216,7 +215,7 @@ using LocPosArray = std::array, 4>; template void test_surface(const Surface &surface, const angle_description_t &desc, const LocPosArray &loc_pos, double expectedError) { - const auto proj = Identity{}; + const auto proj = std::identity{}; for (auto phi : {-175_degree, 0_degree, 175_degree}) { for (auto theta : {5_degree, 90_degree, 175_degree}) { @@ -271,7 +270,7 @@ BOOST_AUTO_TEST_CASE(test_with_data) { const auto boundCov_data = boundCov(samples, mean_data); const auto [mean_test, boundCov_test] = - detail::gaussianMixtureMeanCov(cmps, Identity{}, std::tuple<>{}); + detail::gaussianMixtureMeanCov(cmps, std::identity{}, std::tuple<>{}); CHECK_CLOSE_MATRIX(mean_data, mean_test, 1.e-1); CHECK_CLOSE_MATRIX(boundCov_data, boundCov_test, 1.e-1); @@ -302,7 +301,7 @@ BOOST_AUTO_TEST_CASE(test_with_data_circular) { using detail::CyclicAngle; const auto d = std::tuple, CyclicAngle>{}; const auto [mean_test, boundCov_test] = - detail::gaussianMixtureMeanCov(cmps, Identity{}, d); + detail::gaussianMixtureMeanCov(cmps, std::identity{}, d); BOOST_CHECK(std::abs(detail::difference_periodic(mean_data[0], mean_test[0], 2 * M_PI)) < 1.e-1);