SI  2.5.4
A header only c++ library that provides type safety and user defined literals for handling physical values defined in the International System of Units.
Macros
operator_helpers.h File Reference
#include "cross_unit_operations.h"
#include "detail.h"
Include dependency graph for operator_helpers.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BUILD_UNIT_FROM_DIVISION(RESULTING_UNIT_T, DIVIDEND_UNIT_T, DIVISOR_UNIT_T)
 
#define BUILD_UNIT_FROM_MULTIPLICATION(RESULTING_UNIT, UNIT_LHS, UNIT_RHS)
 

Macro Definition Documentation

◆ BUILD_UNIT_FROM_DIVISION

#define BUILD_UNIT_FROM_DIVISION (   RESULTING_UNIT_T,
  DIVIDEND_UNIT_T,
  DIVISOR_UNIT_T 
)
Value:
template <typename _type, typename _ratio_lhs, typename _type_rhs, \
typename _ratio_rhs> \
constexpr auto operator/(const DIVIDEND_UNIT_T<_type, _ratio_lhs> &lhs, \
const DIVISOR_UNIT_T<_type_rhs, _ratio_rhs> &rhs) { \
return detail::cross_unit_divide<RESULTING_UNIT_T>(lhs, rhs); \
} \
\
template <typename _type, typename _ratio_lhs, typename _type_rhs, \
typename _ratio_rhs> \
constexpr auto operator*(const RESULTING_UNIT_T<_type, _ratio_lhs> &lhs, \
const DIVISOR_UNIT_T<_type_rhs, _ratio_rhs> &rhs) { \
return detail::cross_unit_multiply<DIVIDEND_UNIT_T>(lhs, rhs); \
} \
\
template <typename _type, typename _ratio_lhs, typename _type_rhs, \
typename _ratio_rhs> \
constexpr auto operator*( \
const DIVISOR_UNIT_T<_type, _ratio_lhs> &lhs, \
const RESULTING_UNIT_T<_type_rhs, _ratio_rhs> &rhs) { \
return rhs * lhs; \
} \
\
template <typename _type, typename _ratio_lhs, typename _type_rhs, \
typename _ratio_rhs> \
constexpr auto operator/( \
const DIVIDEND_UNIT_T<_type, _ratio_lhs> &lhs, \
const RESULTING_UNIT_T<_type_rhs, _ratio_rhs> &rhs) { \
return detail::cross_unit_divide<DIVISOR_UNIT_T>(lhs, rhs); \
}
constexpr auto operator/(const _type &lhs, const unit_t< _symbol, _exponent, _rhs_type, _ratio > &rhs)
Definition: unit.h:491

This file is part of "SI" version 2.5.4 A header only c++ library that provides type safety and user defined literals for handling physical values defined in the International System of Units

https://github.com/bernedom/SI

SPDX-License-Identifier: MIT Generate operators for unit conversions. Both macros generate the operators to create new units as well as the inverse operators

◆ BUILD_UNIT_FROM_MULTIPLICATION

#define BUILD_UNIT_FROM_MULTIPLICATION (   RESULTING_UNIT,
  UNIT_LHS,
  UNIT_RHS 
)
Value:
\
template <typename _type, typename _ratio_lhs, typename _type_rhs, \
typename _ratio_rhs> \
constexpr auto operator*(const UNIT_LHS<_type, _ratio_lhs> &lhs, \
const UNIT_RHS<_type_rhs, _ratio_rhs> &rhs) { \
\
return detail::cross_unit_multiply<RESULTING_UNIT>(lhs, rhs); \
} \
\
template <typename _type, typename _ratio_lhs, typename _type_rhs, \
typename _ratio_rhs> \
constexpr auto operator*(const UNIT_RHS<_type, _ratio_lhs> &lhs, \
const UNIT_LHS<_type_rhs, _ratio_rhs> &rhs) { \
return rhs * lhs; \
} \
\
template <typename _type, typename _ratio_lhs, typename _type_rhs, \
typename _ratio_rhs> \
constexpr auto operator/(const RESULTING_UNIT<_type, _ratio_lhs> &lhs, \
const UNIT_LHS<_type_rhs, _ratio_rhs> &rhs) { \
return detail::cross_unit_divide<UNIT_RHS>(lhs, rhs); \
} \
\
template <typename _type, typename _ratio_lhs, typename _type_rhs, \
typename _ratio_rhs> \
constexpr auto operator/(const RESULTING_UNIT<_type, _ratio_lhs> &lhs, \
const UNIT_RHS<_type_rhs, _ratio_rhs> &rhs) { \
return detail::cross_unit_divide<UNIT_LHS>(lhs, rhs); \
}