File indexing completed on 2025-09-13 08:53:53
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/Macros.hh"
0010
0011 #include "../Constant.hh"
0012 #include "../NumericLimits.hh"
0013
0014 namespace celeritas
0015 {
0016 namespace detail
0017 {
0018
0019
0020 enum class QConstant
0021 {
0022 neg_max = -1,
0023 zero = 0,
0024 max = 1
0025 };
0026
0027
0028 template<class T>
0029 CELER_CONSTEXPR_FUNCTION T get_constant(QConstant qc)
0030 {
0031 if constexpr (std::is_floating_point_v<T>)
0032 {
0033
0034 return qc == QConstant::neg_max ? -numeric_limits<T>::infinity()
0035 : qc == QConstant::max ? numeric_limits<T>::infinity()
0036 : 0;
0037 }
0038 else
0039 {
0040
0041 return qc == QConstant::neg_max ? numeric_limits<T>::lowest()
0042 : qc == QConstant::max ? numeric_limits<T>::max()
0043 : 0;
0044 }
0045 }
0046
0047
0048 template<QConstant QC>
0049 struct UnitlessQuantity
0050 {
0051 };
0052
0053
0054
0055 template<class T>
0056 struct AccessorTraits;
0057
0058
0059
0060 template<class ResultType, class ClassType>
0061 struct AccessorTraits<ResultType (ClassType::*)() const>
0062 {
0063 using type = ClassType;
0064 using result_type = ResultType;
0065 };
0066
0067
0068
0069 template<class T>
0070 using AccessorResultType = typename AccessorTraits<T>::result_type;
0071
0072
0073 }
0074 }