ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
invalid_values.hpp
1// This file is part of the ACTS project.
2//
3// Copyright (C) 2016 CERN for the benefit of the ACTS project
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9#pragma once
10
11// Project include(s).
12#include "detray/definitions/detail/qualifiers.hpp"
13
14// System include(s)
15#include <limits>
16#include <type_traits>
17
18namespace detray::detail {
19
21template <typename T>
22 requires std::is_fundamental_v<T> || std::is_enum_v<T>
23DETRAY_HOST_DEVICE constexpr T invalid_value() noexcept {
24 return std::numeric_limits<T>::max();
25}
26
28template <typename T>
29 requires(!std::is_fundamental_v<T>) && (!std::is_enum_v<T>) &&
30 std::is_default_constructible_v<T>
31DETRAY_HOST_DEVICE constexpr T invalid_value() noexcept {
32 return T{};
33}
34
35template <typename T>
36 requires std::is_fundamental_v<T>
37DETRAY_HOST_DEVICE constexpr bool is_invalid_value(const T value) noexcept {
38 if constexpr (std::is_signed_v<T>) {
39 return (value == detail::invalid_value<T>() ||
40 value == -detail::invalid_value<T>());
41 } else {
42 return (value == detail::invalid_value<T>());
43 }
44}
45
46template <typename T>
47 requires(!std::is_fundamental_v<T>)
48DETRAY_HOST_DEVICE constexpr bool is_invalid_value(const T& value) noexcept {
49 return (value == detail::invalid_value<T>());
50}
51
52} // namespace detray::detail
constexpr double T
Magnetic field, native unit (eV*s)/(e*m²).
Definition Units.hpp:168