vtk-m/vtkm/UnaryPredicates.h

57 lines
1.5 KiB
C
Raw Normal View History

//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
2019-04-15 23:24:21 +00:00
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#ifndef vtk_m_UnaryPredicates_h
#define vtk_m_UnaryPredicates_h
#include <vtkm/TypeTraits.h>
#include <vtkm/internal/ExportMacros.h>
2017-05-18 14:29:41 +00:00
namespace vtkm
{
/// Predicate that takes a single argument \c x, and returns
/// True if it is the identity of the Type \p T.
struct IsZeroInitialized
{
2017-05-18 14:29:41 +00:00
template <typename T>
VTKM_EXEC_CONT bool operator()(const T& x) const
{
2017-05-18 14:29:41 +00:00
return (x == vtkm::TypeTraits<T>::ZeroInitialization());
}
};
/// Predicate that takes a single argument \c x, and returns
/// True if it isn't the identity of the Type \p T.
struct NotZeroInitialized
{
2017-05-18 14:29:41 +00:00
template <typename T>
VTKM_EXEC_CONT bool operator()(const T& x) const
{
2017-05-18 14:29:41 +00:00
return (x != vtkm::TypeTraits<T>::ZeroInitialization());
}
};
/// Predicate that takes a single argument \c x, and returns
/// True if and only if \c x is \c false.
/// Note: Requires Type \p T to be convertible to \c bool or implement the
/// ! operator.
struct LogicalNot
{
2017-05-18 14:29:41 +00:00
template <typename T>
VTKM_EXEC_CONT bool operator()(const T& x) const
{
return !x;
}
};
} // namespace vtkm
2018-02-22 13:29:13 +00:00
#endif //vtk_m_UnaryPredicates_h