64 assert((
absQ == 0) and
"Input charge must be zero");
68 constexpr
float absQ() const noexcept {
return 0; }
81 template <
typename P,
typename Q>
83 assert((signedQ != 0) and
"charge must be 0");
115 template <
typename T>
122 template <
typename T>
129 template <
typename P,
typename Q>
154 assert((0 < absQ) and
"Input charge magnitude must be positive");
159 constexpr
float absQ() const noexcept {
return m_absQ; }
161 template <
typename T>
162 constexpr
auto extractCharge(
T qOverP)
const noexcept {
167 template <
typename T>
168 constexpr
auto extractMomentum(
T qOverP)
const noexcept {
171 return extractCharge(qOverP) / qOverP;
174 template <
typename P,
typename Q>
175 constexpr
auto qOverP(
P momentum,
Q signedQ)
const noexcept {
178 assert(abs(signedQ) == m_absQ &&
"inconsistent charge");
185 return lhs.m_absQ ==
rhs.m_absQ;
202 constexpr
AnyCharge(
float absQ) noexcept : m_absQ{absQ} {
203 assert((0 <= absQ) and
"Input charge magnitude must be zero or positive");
207 constexpr
AnyCharge(Neutral ) noexcept {}
209 constexpr
float absQ() const noexcept {
return m_absQ; }
211 template <
typename T>
212 constexpr
auto extractCharge(
T qOverP)
const noexcept {
217 template <
typename T>
218 constexpr
auto extractMomentum(
T qOverP)
const noexcept {
221 return (m_absQ != 0.0
f) ? extractCharge(qOverP) / qOverP : 1.0f / qOverP;
224 template <
typename P,
typename Q>
225 constexpr
auto qOverP(
P momentum,
Q signedQ)
const noexcept {
228 assert(abs(signedQ) == m_absQ &&
"inconsistent charge");
234 return lhs.m_absQ ==
rhs.m_absQ;