The BaseStencil::max() function in Stencils.h causes a compiler error when used.
/usr/local/include/openvdb/math/Stencils.h:155:41: error: conversion from ‘__normal_iterator<const float*,[...]>’ to non-scalar type ‘__normal_iterator<float*,[...]>’ requested
155 | IterType iter = std::max_element(mValues.begin(), mValues.end());
The reason for this issue is that, within the std::max_element() function call, mValues.begin() returns a const_iterator, as the member variable mValues is considered const due to BaseStencil::max() being a const member function.
Solution
The typedef of IterType should be typename BufferType::const_iterator instead of typename BufferType::iterator
Environment
Operating System: (Ubuntu 20.04) Version / Commit SHA: (OpenVDB 10.0.1) Other: (GCC 9.4.0)
Describe the bug
The BaseStencil::max() function in Stencils.h causes a compiler error when used.
To Reproduce
Reason
The reason for this issue is that, within the
std::max_element()
function call,mValues.begin()
returns a const_iterator, as the member variablemValues
is considered const due toBaseStencil::max()
being a const member function.Solution
The typedef of
IterType
should betypename BufferType::const_iterator
instead oftypename BufferType::iterator