Skip to content
Snippets Groups Projects
Commit 7c879a46 authored by Robert Maynard's avatar Robert Maynard Committed by Kitware Robot
Browse files

Merge topic 'correct_gcc4_stdlib_issues'


440ae112 gcc 4.X std::transform impl doesn't like DataArrayTupleRange iterators

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Acked-by: default avatarT.J. Corona <tj.corona@kitware.com>
Merge-request: !6400
parents 913cb4ef 440ae112
Branches
Tags
No related merge requests found
......@@ -117,12 +117,13 @@ struct DeepCopyWorker
const auto srcRange = vtk::DataArrayValueRange(src);
auto dstRange = vtk::DataArrayValueRange(dst);
using SrcT = typename decltype(srcRange)::ValueType;
using DstT = typename decltype(dstRange)::ValueType;
// use transform instead of copy to avoid -Wconversion warnings
std::transform(srcRange.cbegin(), srcRange.cend(), dstRange.begin(),
[](const SrcT v) -> DstT { return static_cast<DstT>(v); });
auto destIter = dstRange.begin();
// use for loop instead of copy to avoid -Wconversion warnings
for (auto v = srcRange.cbegin(); v != srcRange.cend(); ++v, ++destIter)
{
*destIter = static_cast<DstT>(*v);
}
}
// These overloads are split so that the above specializations will be
......
......@@ -56,17 +56,17 @@ struct FunctionWorker
const auto srcTuples = vtk::DataArrayTupleRange<3>(input);
auto dstValues = vtk::DataArrayValueRange<1>(output);
using SrcTupleCRefT = typename decltype(srcTuples)::ConstTupleReferenceType;
using DstValueT = typename decltype(dstValues)::ValueType;
std::transform(srcTuples.cbegin(), srcTuples.cend(), dstValues.begin(),
[&](SrcTupleCRefT tuple) -> DstValueT {
double in[3];
in[0] = static_cast<double>(tuple[0]);
in[1] = static_cast<double>(tuple[1]);
in[2] = static_cast<double>(tuple[2]);
return static_cast<DstValueT>(this->F(in));
});
double in[3];
auto destIter = dstValues.begin();
for (auto tuple = srcTuples.cbegin(); tuple != srcTuples.cend(); ++tuple, ++destIter)
{
in[0] = static_cast<double>((*tuple)[0]);
in[1] = static_cast<double>((*tuple)[1]);
in[2] = static_cast<double>((*tuple)[2]);
*destIter = static_cast<DstValueT>(this->F(in));
}
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment