Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:02

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2025 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 #pragma once
0009 
0010 #include <type_traits>
0011 #include <utility>
0012 
0013 #include "traccc/definitions/qualifiers.hpp"
0014 
0015 namespace traccc {
0016 
0017 template <typename... Ts>
0018 struct tuple {};
0019 
0020 template <typename T, typename... Ts>
0021 struct tuple<T, Ts...> {
0022   TRACCC_HOST_DEVICE constexpr tuple(){};
0023 
0024   constexpr tuple(const tuple &o)
0025     requires(std::is_copy_constructible_v<T> &&
0026              (std::is_copy_constructible_v<Ts> && ...))
0027   = default;
0028 
0029   template <typename U, typename... Us>
0030     requires std::is_constructible_v<T, U &&> &&
0031                  std::is_constructible_v<tuple<Ts...>, Us &&...>
0032   TRACCC_HOST_DEVICE explicit constexpr tuple(const tuple<U, Us...> &o)
0033       : v(o.v), r(o.r) {}
0034 
0035   constexpr tuple(tuple &&o) noexcept
0036     requires(std::is_move_constructible_v<T> &&
0037              (std::is_move_constructible_v<Ts> && ...))
0038   = default;
0039 
0040   template <typename U, typename... Us>
0041     requires std::is_constructible_v<T, U &&> &&
0042                  std::is_constructible_v<tuple<Ts...>, Us &&...>
0043   TRACCC_HOST_DEVICE explicit constexpr tuple(tuple<U, Us...> &&o)
0044       : v(std::move(o.v)), r(std::move(o.r)) {}
0045 
0046   template <typename U, typename... Us>
0047     requires std::is_constructible_v<T, U &&> &&
0048                  std::is_constructible_v<tuple<Ts...>, Us &&...> &&
0049                  (!(std::is_same_v<tuple, U> ||
0050                     (std::is_same_v<tuple, Us> || ...)))
0051   TRACCC_HOST_DEVICE explicit constexpr tuple(U &&_v, Us &&..._r)
0052       : v(std::forward<U>(_v)), r(std::forward<Us>(_r)...) {}
0053 
0054   constexpr ~tuple() noexcept = default;
0055 
0056   constexpr tuple &operator=(const tuple &other)
0057     requires(std::is_copy_assignable_v<T> &&
0058              (std::is_copy_assignable_v<Ts> && ...))
0059   = default;
0060 
0061   template <typename U, typename... Us>
0062   TRACCC_HOST_DEVICE constexpr tuple &operator=(const tuple<U, Us...> &other)
0063     requires(std::is_assignable_v<T &, const U &> &&
0064              (std::is_assignable_v<Ts &, const Us &> && ...))
0065   {
0066     v = other.v;
0067     r = other.r;
0068     return *this;
0069   }
0070 
0071   constexpr tuple &operator=(tuple &&other) noexcept
0072     requires(std::is_move_assignable_v<T> &&
0073              (std::is_move_assignable_v<Ts> && ...))
0074   = default;
0075 
0076   template <typename U, typename... Us>
0077   TRACCC_HOST_DEVICE constexpr tuple &operator=(tuple<U, Us...> &&other)
0078     requires(std::is_assignable_v<T &, U> &&
0079              (std::is_assignable_v<Ts &, Us> && ...))
0080   {
0081     v = std::move(other.v);
0082     r = std::move(other.r);
0083     return *this;
0084   }
0085 
0086   T v;
0087   tuple<Ts...> r;
0088 };
0089 }  // namespace traccc