File indexing completed on 2025-01-18 09:54:48
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "corecel/Macros.hh"
0011
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 template<class T>
0055 struct AccessorTraits;
0056
0057
0058
0059 template<class ResultType, class ClassType>
0060 struct AccessorTraits<ResultType (ClassType::*)() const>
0061 {
0062 using type = ClassType;
0063 using result_type = ResultType;
0064 };
0065
0066
0067
0068 template<class T>
0069 using AccessorResultType = typename AccessorTraits<T>::result_type;
0070
0071
0072 }
0073 }