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

Remove template parameter for IncrementBy2

THe IncrementBy2 test type previously allowed any subtype including
floating point numbers. The meaning of this is actually a little unclear
and the feature was causing implicit type conversion warnings that were
hard to template out. The utility of of templating this class is dubious
in the first place, so class is now a fixed type.

I'm a little unsure whether we should keep this test class at all. It's
math operations are ad hoc and it could be difficult to determine if a
problem is caused by an actual problem or just bad math operators.
parent 209053b7
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
namespace fancy_array_detail namespace fancy_array_detail
{ {
template<typename T>
class IncrementBy2 class IncrementBy2
{ {
public: public:
...@@ -48,10 +47,10 @@ public: ...@@ -48,10 +47,10 @@ public:
} }
VTKM_EXEC_CONT_EXPORT VTKM_EXEC_CONT_EXPORT
explicit IncrementBy2(T value): Value(2*value) { } explicit IncrementBy2(vtkm::Id value): Value(2*value) { }
VTKM_EXEC_CONT_EXPORT VTKM_EXEC_CONT_EXPORT
operator T() const { return this->Value; } operator vtkm::Id() const { return this->Value; }
VTKM_EXEC_CONT_EXPORT VTKM_EXEC_CONT_EXPORT
IncrementBy2 operator+(const IncrementBy2 &rhs) const IncrementBy2 operator+(const IncrementBy2 &rhs) const
...@@ -82,13 +81,12 @@ public: ...@@ -82,13 +81,12 @@ public:
{ os << v.Value; return os; } { os << v.Value; return os; }
T Value; vtkm::Id Value;
}; };
template<typename T> IncrementBy2 TestValue(vtkm::Id index, IncrementBy2)
IncrementBy2<T> TestValue(vtkm::Id index, IncrementBy2<T>)
{ {
return IncrementBy2<T>(::TestValue(index, T())); return IncrementBy2(::TestValue(index, vtkm::Id()));
} }
template<typename ValueType> template<typename ValueType>
...@@ -110,32 +108,22 @@ struct ValueSquared ...@@ -110,32 +108,22 @@ struct ValueSquared
ValueType operator()(U u) const ValueType operator()(U u) const
{ return vtkm::dot(u, u); } { return vtkm::dot(u, u); }
template<typename U>
VTKM_EXEC_CONT_EXPORT VTKM_EXEC_CONT_EXPORT
ValueType operator()( ::fancy_array_detail::IncrementBy2<U> u) const ValueType operator()( ::fancy_array_detail::IncrementBy2 u) const
{ return ValueType( vtkm::dot(u.Value, u.Value) ); } { return ValueType( vtkm::dot(u.Value, u.Value) ); }
}; };
} }
namespace vtkm { VTKM_BASIC_TYPE_VECTOR(::fancy_array_detail::IncrementBy2)
// Allows us to use vec traits with IncrementBy2, will make look like
// a vector of a single component
template< typename T >
struct VecTraits< ::fancy_array_detail::IncrementBy2<T> > :
public vtkm::internal::VecTraitsBasic< ::fancy_array_detail::IncrementBy2<T> >
{ };
}
namespace vtkm { namespace testing { namespace vtkm { namespace testing {
template<typename T> template<>
struct TypeName< ::fancy_array_detail::IncrementBy2<T> > struct TypeName< ::fancy_array_detail::IncrementBy2 >
{ {
static std::string Name() static std::string Name()
{ {
std::stringstream stream; return std::string("fancy_array_detail::IncrementBy2");
stream << "fancy_array_detail::IncrementBy2< " << TypeName<T>::Name() << " >";
return stream.str();
} }
}; };
...@@ -505,8 +493,7 @@ private: ...@@ -505,8 +493,7 @@ private:
vtkm::Float64, vtkm::Float64,
vtkm::Vec<vtkm::Float64,3>, vtkm::Vec<vtkm::Float64,3>,
vtkm::Vec<vtkm::Float32,4>, vtkm::Vec<vtkm::Float32,4>,
::fancy_array_detail::IncrementBy2 < vtkm::Int32 >, ::fancy_array_detail::IncrementBy2
::fancy_array_detail::IncrementBy2 < vtkm::Float32 >
> >
{ }; { };
......
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