Skip to content

Commit 4b7328d

Browse files
authored
Merge pull request #2017 from sideeffects/sendupstream_nodiscard
Add [[nodiscard]] to confusing math functions.
2 parents 6e7ab0d + f8a1b1e commit 4b7328d

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

openvdb/openvdb/math/Mat3.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ class Mat3: public Mat<3, T>
420420
}
421421

422422
/// @brief Return the cofactor matrix of this matrix.
423-
Mat3 cofactor() const
423+
[[nodiscard]] Mat3 cofactor() const
424424
{
425425
return Mat3<T>(
426426
MyBase::mm[4] * MyBase::mm[8] - MyBase::mm[5] * MyBase::mm[7],
@@ -435,7 +435,7 @@ class Mat3: public Mat<3, T>
435435
}
436436

437437
/// Return the adjoint of this matrix, i.e., the transpose of its cofactor.
438-
Mat3 adjoint() const
438+
[[nodiscard]] Mat3 adjoint() const
439439
{
440440
return Mat3<T>(
441441
MyBase::mm[4] * MyBase::mm[8] - MyBase::mm[5] * MyBase::mm[7],
@@ -462,7 +462,7 @@ class Mat3: public Mat<3, T>
462462

463463
/// returns inverse of this
464464
/// @throws ArithmeticError if singular
465-
Mat3 inverse(T tolerance = 0) const
465+
[[nodiscard]] Mat3 inverse(T tolerance = 0) const
466466
{
467467
Mat3<T> inv(this->adjoint());
468468

@@ -518,7 +518,7 @@ class Mat3: public Mat<3, T>
518518

519519
/// @brief Treat @a diag as a diagonal matrix and return the product
520520
/// of this matrix with @a diag (from the right).
521-
Mat3 timesDiagonal(const Vec3<T>& diag) const
521+
[[nodiscard]] Mat3 timesDiagonal(const Vec3<T>& diag) const
522522
{
523523
Mat3 ret(*this);
524524

openvdb/openvdb/math/Mat4.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ class Mat4: public Mat<4, T>
469469
}
470470

471471
/// @return transpose of this
472-
Mat4 transpose() const
472+
[[nodiscard]] Mat4 transpose() const
473473
{
474474
return Mat4<T>(
475475
MyBase::mm[ 0], MyBase::mm[ 4], MyBase::mm[ 8], MyBase::mm[12],
@@ -482,7 +482,7 @@ class Mat4: public Mat<4, T>
482482

483483
/// @return inverse of this
484484
/// @throw ArithmeticError if singular
485-
Mat4 inverse(T tolerance = 0) const
485+
[[nodiscard]] Mat4 inverse(T tolerance = 0) const
486486
{
487487
//
488488
// inv [ A | b ] = [ E | f ] A: 3x3, b: 3x1, c': 1x3 d: 1x1

pendingchanges/math_nodiscard.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
OpenVDB:
2+
API Changes:
3+
Mat3 and Mat4 functions have been marked [[nodiscard]] where it
4+
may be confusing if they are operating in place or returning a
5+
result, in particular tranpose, invert, adjoint, and
6+
timesDiagonal.

0 commit comments

Comments
 (0)