Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:05

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 // Project include(s)
0012 #include "detray/algebra/concepts.hpp"
0013 #include "detray/definitions/indexing.hpp"
0014 #include "detray/utils/type_traits.hpp"
0015 
0016 // System include(s)
0017 #include <concepts>
0018 #include <type_traits>
0019 
0020 namespace detray::concepts {
0021 
0022 template <typename T, typename... U>
0023 concept any_of = std::disjunction_v<std::is_same<T, U>...>;
0024 
0025 /// Same, except for cv qualifiers and reference
0026 template <typename T, typename U>
0027 concept same_as_cvref =
0028     std::same_as<std::remove_cvref_t<T>, std::remove_cvref_t<U>>;
0029 
0030 /// Concept for detecting when a type is a non-const version of another
0031 template <typename T, typename U>
0032 concept same_as_no_const = std::same_as<std::remove_cv_t<T>, U>;
0033 
0034 /// Type identifier concept
0035 template <typename T>
0036 concept type_id = std::is_enum_v<T>;
0037 
0038 /// Concept that checks if a type models an interval of some value that can
0039 /// be obtained with 'get'.
0040 template <typename I>
0041 concept interval = requires(I i) {
0042   requires(!std::is_fundamental_v<std::remove_cvref_t<I>>);
0043 
0044   { detray::detail::get<0>(i) } -> concepts::arithmetic_cvref;
0045 
0046   { detray::detail::get<1>(i) } -> concepts::arithmetic_cvref;
0047 };
0048 
0049 /// Concept that checks whether a type can be incremented with arbitrary
0050 /// integer values.
0051 template <typename T>
0052 concept random_access_incrementable = requires(T i, const T j, int n) {
0053   { i += n } -> std::same_as<T &>;
0054   { j + n } -> std::same_as<T>;
0055   { n + j } -> std::same_as<T>;
0056   { i -= n } -> std::same_as<T &>;
0057   { j - n } -> std::same_as<T>;
0058 };
0059 }  // namespace detray::concepts