2016-10-28 03:14:29 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
|
|
|
// 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.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Copyright 2016 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2016-10-28 03:14:29 +00:00
|
|
|
// Copyright 2016 UT-Battelle, LLC.
|
|
|
|
// Copyright 2016 Los Alamos National Security.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2016-10-28 03:14:29 +00:00
|
|
|
// the U.S. Government retains certain rights in this software.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
|
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
|
|
|
// this software.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtk_m_internal_ArrayPortalValueReference_h
|
|
|
|
#define vtk_m_internal_ArrayPortalValueReference_h
|
|
|
|
|
|
|
|
#include <vtkm/TypeTraits.h>
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/Types.h>
|
2016-10-28 03:14:29 +00:00
|
|
|
#include <vtkm/VecTraits.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace internal
|
|
|
|
{
|
2016-10-28 03:14:29 +00:00
|
|
|
|
|
|
|
/// \brief A value class for returning setable values of an ArrayPortal
|
|
|
|
///
|
|
|
|
/// \c ArrayPortal classes have a pair of \c Get and \c Set methods that
|
2018-01-30 00:24:31 +00:00
|
|
|
/// retrieve and store values in the array. This is to make it easy to
|
2016-10-28 03:14:29 +00:00
|
|
|
/// implement the \c ArrayPortal even it is not really an array. However, there
|
|
|
|
/// are some cases where the code structure expects a reference to a value that
|
|
|
|
/// can be set. For example, the \c IteratorFromArrayPortal class must return
|
|
|
|
/// something from its * operator that behaves like a reference.
|
|
|
|
///
|
|
|
|
/// For cases of this nature \c ArrayPortalValueReference can be used. This
|
|
|
|
/// class is constructured with an \c ArrayPortal and an index into the array.
|
|
|
|
/// The object then behaves like a reference to the value in the array. If you
|
|
|
|
/// set this reference object to a new value, it will call \c Set on the
|
|
|
|
/// \c ArrayPortal to insert the value into the array.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ArrayPortalType>
|
2016-10-28 03:14:29 +00:00
|
|
|
struct ArrayPortalValueReference
|
|
|
|
{
|
|
|
|
using ValueType = typename ArrayPortalType::ValueType;
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
ArrayPortalValueReference(const ArrayPortalType& portal, vtkm::Id index)
|
|
|
|
: Portal(portal)
|
|
|
|
, Index(index)
|
|
|
|
{
|
|
|
|
}
|
2016-10-28 03:14:29 +00:00
|
|
|
|
2019-02-09 23:49:17 +00:00
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
VTKM_EXEC_CONT
|
|
|
|
ValueType Get() const { return this->Portal.Get(this->Index); }
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
VTKM_EXEC_CONT
|
|
|
|
void Set(ValueType&& value) { this->Portal.Set(this->Index, std::move(value)); }
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
VTKM_EXEC_CONT
|
|
|
|
void Set(const ValueType& value) { this->Portal.Set(this->Index, value); }
|
|
|
|
|
2016-10-28 03:14:29 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void Swap(ArrayPortalValueReference<ArrayPortalType>& rhs) throw()
|
2016-10-28 03:14:29 +00:00
|
|
|
{
|
|
|
|
//we need use the explicit type not a proxy temp object
|
|
|
|
//A proxy temp object would point to the same underlying data structure
|
|
|
|
//and would not hold the old value of *this once *this was set to rhs.
|
|
|
|
const ValueType aValue = *this;
|
|
|
|
*this = rhs;
|
|
|
|
rhs = aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
2019-02-12 12:41:20 +00:00
|
|
|
template <typename OtherPortalType>
|
|
|
|
VTKM_EXEC_CONT ArrayPortalValueReference<ArrayPortalType>& operator=(
|
|
|
|
const ArrayPortalValueReference<OtherPortalType>& rhs)
|
2016-10-28 03:14:29 +00:00
|
|
|
{
|
2019-02-12 12:41:20 +00:00
|
|
|
this->Set(static_cast<ValueType>(rhs.Portal.Get(rhs.Index)));
|
2016-10-28 03:14:29 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
2019-02-12 12:41:20 +00:00
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator=(T&& value)
|
2016-10-28 03:14:29 +00:00
|
|
|
{
|
2019-02-12 12:41:20 +00:00
|
|
|
this->Set(std::forward<T>(value));
|
2016-10-28 03:14:29 +00:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
operator ValueType(void) const { return this->Portal.Get(this->Index); }
|
2016-10-28 03:14:29 +00:00
|
|
|
|
2019-02-09 23:49:17 +00:00
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator+=(const T& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs += rhs;
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator+=(const ArrayPortalValueReference<T>& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs += rhs.Get();
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator-=(const T& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs -= rhs;
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator-=(const ArrayPortalValueReference<T>& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs -= rhs.Get();
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator*=(const T& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs *= rhs;
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator*=(const ArrayPortalValueReference<T>& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs *= rhs.Get();
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator/=(const T& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs /= rhs;
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator/=(const ArrayPortalValueReference<T>& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs /= rhs.Get();
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator&=(const T& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs &= rhs;
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator&=(const ArrayPortalValueReference<T>& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs &= rhs.Get();
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator|=(const T& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs |= rhs;
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator|=(const ArrayPortalValueReference<T>& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs |= rhs.Get();
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator^=(const T& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs ^= rhs;
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator^=(const ArrayPortalValueReference<T>& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs ^= rhs.Get();
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator>>=(const T& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs >>= rhs;
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator>>=(const ArrayPortalValueReference<T>& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs >>= rhs.Get();
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator<<=(const T& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs <<= rhs;
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC_CONT ValueType operator<<=(const ArrayPortalValueReference<T>& rhs)
|
|
|
|
{
|
|
|
|
ValueType lhs = this->Get();
|
|
|
|
lhs <<= rhs.Get();
|
|
|
|
this->Set(lhs);
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2016-10-28 03:14:29 +00:00
|
|
|
const ArrayPortalType& Portal;
|
|
|
|
vtkm::Id Index;
|
|
|
|
};
|
|
|
|
|
|
|
|
//implement a custom swap function, since the std::swap won't work
|
|
|
|
//since we return RValues instead of Lvalues
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
|
|
|
void swap(vtkm::internal::ArrayPortalValueReference<T> a,
|
|
|
|
vtkm::internal::ArrayPortalValueReference<T> b)
|
2016-10-28 03:14:29 +00:00
|
|
|
{
|
|
|
|
a.Swap(b);
|
|
|
|
}
|
2018-05-14 19:53:11 +00:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void swap(vtkm::internal::ArrayPortalValueReference<T> a,
|
|
|
|
typename vtkm::internal::ArrayPortalValueReference<T>::ValueType& b)
|
|
|
|
{
|
|
|
|
using ValueType = typename vtkm::internal::ArrayPortalValueReference<T>::ValueType;
|
|
|
|
const ValueType tmp = a;
|
|
|
|
a = b;
|
|
|
|
b = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void swap(typename vtkm::internal::ArrayPortalValueReference<T>::ValueType& a,
|
|
|
|
vtkm::internal::ArrayPortalValueReference<T> b)
|
|
|
|
{
|
|
|
|
using ValueType = typename vtkm::internal::ArrayPortalValueReference<T>::ValueType;
|
|
|
|
const ValueType tmp = b;
|
|
|
|
b = a;
|
|
|
|
a = tmp;
|
|
|
|
}
|
2019-02-09 23:49:17 +00:00
|
|
|
|
|
|
|
// The reason why all the operators on ArrayPortalValueReference are defined outside of the class
|
|
|
|
// is so that in the case that the operator in question is not defined in the value type, these
|
|
|
|
// operators will not be instantiated (and therefore cause a compile error) unless they are
|
|
|
|
// directly used (in which case a compile error is appropriate).
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator==(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() == rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() == rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator==(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() == rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() == rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator==(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs == rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs == rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator!=(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() != rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() != rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator!=(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() != rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() != rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator!=(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs != rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs != rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator<(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() < rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() < rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator<(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() < rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() < rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator<(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs < rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs < rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator>(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() > rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() > rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator>(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() > rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() > rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator>(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs > rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs > rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator<=(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() <= rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() <= rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator<=(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() <= rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() <= rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator<=(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs <= rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs <= rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator>=(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() >= rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() >= rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator>=(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() >= rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() >= rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator>=(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs >= rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs >= rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator+(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() + rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() + rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator+(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() + rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() + rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator+(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs + rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs + rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator-(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() - rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() - rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator-(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() - rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() - rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator-(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs - rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs - rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator*(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() * rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() * rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator*(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() * rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() * rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator*(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs * rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs * rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator/(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() / rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() / rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator/(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() / rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() / rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator/(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs / rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs / rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator%(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() % rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() % rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator%(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() % rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() % rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator%(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs % rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs % rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator^(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() ^ rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() ^ rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator^(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() ^ rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() ^ rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator^(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs ^ rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs ^ rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator|(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() | rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() | rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator|(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() | rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() | rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator|(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs | rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs | rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator&(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() & rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() & rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator&(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() & rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() & rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator&(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs & rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs & rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator<<(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() << rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() << rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator<<(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() << rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() << rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator<<(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs << rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs << rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator>>(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() >> rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() >> rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator>>(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() >> rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() >> rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator>>(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs >> rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs >> rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename PortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator~(const ArrayPortalValueReference<PortalType>& ref)
|
|
|
|
-> decltype(~ref.Get())
|
|
|
|
{
|
|
|
|
return ~ref.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename PortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator!(const ArrayPortalValueReference<PortalType>& ref)
|
|
|
|
-> decltype(!ref.Get())
|
|
|
|
{
|
|
|
|
return !ref.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator&&(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() && rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() && rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator&&(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() && rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() && rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator&&(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs && rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs && rhs.Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator||(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const typename LhsPortalType::ValueType& rhs)
|
|
|
|
-> decltype(lhs.Get() || rhs)
|
|
|
|
{
|
|
|
|
return lhs.Get() || rhs;
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename LhsPortalType, typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator||(const ArrayPortalValueReference<LhsPortalType>& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs.Get() || rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs.Get() || rhs.Get();
|
|
|
|
}
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
|
|
|
template <typename RhsPortalType>
|
|
|
|
VTKM_EXEC_CONT auto operator||(const typename RhsPortalType::ValueType& lhs,
|
|
|
|
const ArrayPortalValueReference<RhsPortalType>& rhs)
|
|
|
|
-> decltype(lhs || rhs.Get())
|
|
|
|
{
|
|
|
|
return lhs || rhs.Get();
|
|
|
|
}
|
2016-10-28 03:14:29 +00:00
|
|
|
}
|
|
|
|
} // namespace vtkm::internal
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
2016-10-28 03:14:29 +00:00
|
|
|
|
|
|
|
// Make specialization for TypeTraits and VecTraits so that the reference
|
|
|
|
// behaves the same as the value.
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename PortalType>
|
|
|
|
struct TypeTraits<vtkm::internal::ArrayPortalValueReference<PortalType>>
|
|
|
|
: vtkm::TypeTraits<typename vtkm::internal::ArrayPortalValueReference<PortalType>::ValueType>
|
|
|
|
{
|
|
|
|
};
|
2016-10-28 03:14:29 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename PortalType>
|
|
|
|
struct VecTraits<vtkm::internal::ArrayPortalValueReference<PortalType>>
|
|
|
|
: vtkm::VecTraits<typename vtkm::internal::ArrayPortalValueReference<PortalType>::ValueType>
|
|
|
|
{
|
|
|
|
};
|
2016-10-28 03:14:29 +00:00
|
|
|
|
|
|
|
} // namespace vtkm
|
|
|
|
|
|
|
|
#endif //vtk_m_internal_ArrayPortalValueReference_h
|