Commit cc5b9a01 authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

Add casts to FunctorsGeneral.h

If you are using the classes in `FunctorsGeneral.h`, you specify both
the result type and the type of the operands. Presumably you are already
comfortable with any type conversions. So let them keep.
parent d9c988b2
......@@ -49,7 +49,7 @@ struct WrappedBinaryOperator
template <typename Argument1, typename Argument2>
VTKM_EXEC_CONT ResultType operator()(const Argument1& x, const Argument2& y) const
{
return m_f(x, y);
return static_cast<ResultType>(m_f(x, y));
}
VTKM_SUPPRESS_EXEC_WARNINGS
......@@ -60,7 +60,7 @@ struct WrappedBinaryOperator
{
using ValueTypeX = typename vtkm::internal::ArrayPortalValueReference<Argument1>::ValueType;
using ValueTypeY = typename vtkm::internal::ArrayPortalValueReference<Argument2>::ValueType;
return m_f((ValueTypeX)x, (ValueTypeY)y);
return static_cast<ResultType>(m_f((ValueTypeX)x, (ValueTypeY)y));
}
VTKM_SUPPRESS_EXEC_WARNINGS
......@@ -70,7 +70,7 @@ struct WrappedBinaryOperator
const vtkm::internal::ArrayPortalValueReference<Argument2>& y) const
{
using ValueTypeY = typename vtkm::internal::ArrayPortalValueReference<Argument2>::ValueType;
return m_f(x, (ValueTypeY)y);
return static_cast<ResultType>(m_f(x, (ValueTypeY)y));
}
VTKM_SUPPRESS_EXEC_WARNINGS
......@@ -80,7 +80,7 @@ struct WrappedBinaryOperator
const Argument2& y) const
{
using ValueTypeX = typename vtkm::internal::ArrayPortalValueReference<Argument1>::ValueType;
return m_f((ValueTypeX)x, y);
return static_cast<ResultType>(m_f((ValueTypeX)x, y));
}
};
......@@ -147,11 +147,11 @@ struct ReduceKernel : vtkm::exec::FunctorBase
{
//This will only occur for a single index value, so this is the case
//that needs to handle the initialValue
T partialSum = BinaryOperator(this->InitialValue, this->Portal.Get(offset));
T partialSum = static_cast<T>(BinaryOperator(this->InitialValue, this->Portal.Get(offset)));
vtkm::Id currentIndex = offset + 1;
while (currentIndex < this->PortalLength)
{
partialSum = BinaryOperator(partialSum, this->Portal.Get(currentIndex));
partialSum = static_cast<T>(BinaryOperator(partialSum, this->Portal.Get(currentIndex)));
++currentIndex;
}
return partialSum;
......@@ -160,10 +160,11 @@ struct ReduceKernel : vtkm::exec::FunctorBase
{
//optimize the usecase where all values are valid and we don't
//need to check that we might go out of bounds
T partialSum = BinaryOperator(this->Portal.Get(offset), this->Portal.Get(offset + 1));
T partialSum =
static_cast<T>(BinaryOperator(this->Portal.Get(offset), this->Portal.Get(offset + 1)));
for (int i = 2; i < reduceWidth; ++i)
{
partialSum = BinaryOperator(partialSum, this->Portal.Get(offset + i));
partialSum = static_cast<T>(BinaryOperator(partialSum, this->Portal.Get(offset + i)));
}
return partialSum;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment