Skip to content

Commit ee4f8fa

Browse files
committed
Fixed another occurance of static non-trivial construction
Signed-off-by: Nick Avramoussis <4256455+Idclip@users.noreply.github.com>
1 parent e0bc5f4 commit ee4f8fa

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

openvdb/openvdb/math/ConjGradient.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class SparseStencilMatrix
245245
class ConstRow;
246246
class RowEditor;
247247

248-
static const ValueType sZeroValue;
248+
static inline constexpr ValueType sZeroValue = zeroVal<ValueType>();
249249

250250
/// Construct an @a n x @a n matrix with at most @a STENCIL_SIZE nonzero elements per row.
251251
SparseStencilMatrix(SizeType n);
@@ -814,10 +814,6 @@ Vector<T>::str() const
814814
////////////////////////////////////////
815815

816816

817-
template<typename ValueType, SizeType STENCIL_SIZE>
818-
const ValueType SparseStencilMatrix<ValueType, STENCIL_SIZE>::sZeroValue = zeroVal<ValueType>();
819-
820-
821817
template<typename ValueType, SizeType STENCIL_SIZE>
822818
inline
823819
SparseStencilMatrix<ValueType, STENCIL_SIZE>::SparseStencilMatrix(SizeType numRows)

openvdb/openvdb/math/Math.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ namespace OPENVDB_VERSION_NAME {
6767
/// @note A zeroVal<T>() specialization must be defined for each @c ValueType T
6868
/// that cannot be constructed using the form @c T(0). For example, @c std::string(0)
6969
/// treats 0 as @c nullptr and throws a @c std::logic_error.
70-
template<typename T> inline T zeroVal() { return T(0); }
70+
template<typename T> inline constexpr T zeroVal() { return T(0); }
7171
/// Return the @c std::string value that corresponds to zero.
7272
template<> inline std::string zeroVal<std::string>() { return ""; }
7373
/// Return the @c bool value that corresponds to zero.
74-
template<> inline bool zeroVal<bool>() { return false; }
74+
template<> inline constexpr bool zeroVal<bool>() { return false; }
7575

7676
namespace math {
7777

0 commit comments

Comments
 (0)