xo-unit: bugfix: fix static asserts on operator+= operator-=
This commit is contained in:
parent
b56cd3e390
commit
3dd48ee1e7
1 changed files with 4 additions and 8 deletions
|
|
@ -406,13 +406,11 @@ namespace xo {
|
||||||
* @pre @p y must have the same dimension as @c *this.
|
* @pre @p y must have the same dimension as @c *this.
|
||||||
*
|
*
|
||||||
* @param y quantity to add
|
* @param y quantity to add
|
||||||
* @retval this quantity after adding y
|
* @return this quantity after adding y
|
||||||
**/
|
**/
|
||||||
template <typename Quantity2>
|
template <typename Quantity2>
|
||||||
quantity & operator+=(Quantity2 y) {
|
quantity & operator+=(Quantity2 y) {
|
||||||
static_assert(std::same_as<
|
static_assert(same_dimension_v<unit_type, typename Quantity2::unit_type>);
|
||||||
typename unit_type::canon_type,
|
|
||||||
typename Quantity2::unit_type::canon_type >);
|
|
||||||
|
|
||||||
/* relying on assignment that correctly converts-to-lhs-units */
|
/* relying on assignment that correctly converts-to-lhs-units */
|
||||||
quantity y2 = y;
|
quantity y2 = y;
|
||||||
|
|
@ -427,13 +425,11 @@ namespace xo {
|
||||||
* @pre @p y must have the same dimensions as @c *this
|
* @pre @p y must have the same dimensions as @c *this
|
||||||
*
|
*
|
||||||
* @param y quantity to subtract
|
* @param y quantity to subtract
|
||||||
* @retval this quantity after subtracting y
|
* @return this quantity after subtracting y
|
||||||
**/
|
**/
|
||||||
template <typename Quantity2>
|
template <typename Quantity2>
|
||||||
quantity & operator-=(Quantity2 y) {
|
quantity & operator-=(Quantity2 y) {
|
||||||
static_assert(std::same_as<
|
static_assert(same_dimension_v<unit_type, typename Quantity2::unit_type>);
|
||||||
typename unit_type::canon_type,
|
|
||||||
typename Quantity2::unit_type::canon_type >);
|
|
||||||
|
|
||||||
quantity y2 = y;
|
quantity y2 = y;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue