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/definitions/detail/qualifiers.hpp"
0013 
0014 // System include(s)
0015 #include <limits>
0016 #include <type_traits>
0017 
0018 namespace detray::detail {
0019 
0020 /// Invalid value for fundamental types - constexpr
0021 template <typename T>
0022   requires std::is_fundamental_v<T> || std::is_enum_v<T>
0023 DETRAY_HOST_DEVICE constexpr T invalid_value() noexcept {
0024   return std::numeric_limits<T>::max();
0025 }
0026 
0027 /// Invalid value for types that cannot be constructed constexpr, e.g. Eigen
0028 template <typename T>
0029   requires(!std::is_fundamental_v<T>) && (!std::is_enum_v<T>) &&
0030           std::is_default_constructible_v<T>
0031 DETRAY_HOST_DEVICE constexpr T invalid_value() noexcept {
0032   return T{};
0033 }
0034 
0035 template <typename T>
0036   requires std::is_fundamental_v<T>
0037 DETRAY_HOST_DEVICE constexpr bool is_invalid_value(const T value) noexcept {
0038   if constexpr (std::is_signed_v<T>) {
0039     return (value == detail::invalid_value<T>() ||
0040             value == -detail::invalid_value<T>());
0041   } else {
0042     return (value == detail::invalid_value<T>());
0043   }
0044 }
0045 
0046 template <typename T>
0047   requires(!std::is_fundamental_v<T>)
0048 DETRAY_HOST_DEVICE constexpr bool is_invalid_value(const T& value) noexcept {
0049   return (value == detail::invalid_value<T>());
0050 }
0051 
0052 }  // namespace detray::detail