Skip to content

Commit

Permalink
Cast to bool when testing value of enum class flag
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomofiorin committed Jul 18, 2023
1 parent 06e61c0 commit 83b0ad2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/colvar_rotation_derivative.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ inline constexpr rotation_derivative_dldq operator|(rotation_derivative_dldq Lhs
static_cast<std::underlying_type<rotation_derivative_dldq>::type>(Rhs));
}

inline constexpr rotation_derivative_dldq operator&(rotation_derivative_dldq Lhs, rotation_derivative_dldq Rhs) {
return static_cast<rotation_derivative_dldq>(
static_cast<std::underlying_type<rotation_derivative_dldq>::type>(Lhs) &
static_cast<std::underlying_type<rotation_derivative_dldq>::type>(Rhs));
inline constexpr bool operator&(rotation_derivative_dldq Lhs, rotation_derivative_dldq Rhs)
{
return (static_cast<std::underlying_type<rotation_derivative_dldq>::type>(Lhs) &
static_cast<std::underlying_type<rotation_derivative_dldq>::type>(Rhs));
}

/// \brief Helper class for calculating the derivative of rotation
Expand Down Expand Up @@ -79,7 +79,7 @@ struct rotation_derivative {
* with respect to atoms.
*/
void prepare_derivative(rotation_derivative_dldq require_dl_dq) {
if (static_cast<std::underlying_type<rotation_derivative_dldq>::type>(require_dl_dq & rotation_derivative_dldq::use_dl)) {
if (require_dl_dq & rotation_derivative_dldq::use_dl) {
const auto &Q0 = m_rot.S_eigvec[0].data;
tmp_Q0Q0[0][0] = Q0[0] * Q0[0];
tmp_Q0Q0[0][1] = Q0[0] * Q0[1];
Expand All @@ -98,7 +98,7 @@ struct rotation_derivative {
tmp_Q0Q0[3][2] = Q0[3] * Q0[2];
tmp_Q0Q0[3][3] = Q0[3] * Q0[3];
}
if (static_cast<std::underlying_type<rotation_derivative_dldq>::type>(require_dl_dq & rotation_derivative_dldq::use_dq)) {
if (require_dl_dq & rotation_derivative_dldq::use_dq) {
const auto &Q0 = m_rot.S_eigvec[0].data;
const auto &Q1 = m_rot.S_eigvec[1].data;
const auto &Q2 = m_rot.S_eigvec[2].data;
Expand Down

0 comments on commit 83b0ad2

Please sign in to comment.