Commit 1e6c30b7 authored by Allison Vacanti's avatar Allison Vacanti

Make pair construction rvalue-friendly.

parent 6c6ebaff
......@@ -73,6 +73,16 @@ struct Pair
{
}
VTKM_EXEC_CONT
Pair(FirstType&& firstSrc, SecondType&& secondSrc)
: first(std::move(firstSrc))
, second(std::move(secondSrc))
{
}
Pair(const Pair&) = default;
Pair(Pair&&) = default;
template <typename U1, typename U2>
VTKM_EXEC_CONT Pair(const vtkm::Pair<U1, U2>& src)
: first(src.first)
......@@ -80,6 +90,13 @@ struct Pair
{
}
template <typename U1, typename U2>
VTKM_EXEC_CONT Pair(vtkm::Pair<U1, U2>&& src)
: first(std::move(src.first))
, second(std::move(src.second))
{
}
template <typename U1, typename U2>
VTKM_EXEC_CONT Pair(const std::pair<U1, U2>& src)
: first(src.first)
......@@ -87,8 +104,16 @@ struct Pair
{
}
template <typename U1, typename U2>
VTKM_EXEC_CONT Pair(std::pair<U1, U2>&& src)
: first(std::move(src.first))
, second(std::move(src.second))
{
}
vtkm::Pair<FirstType, SecondType>& operator=(const vtkm::Pair<FirstType, SecondType>& src) =
default;
vtkm::Pair<FirstType, SecondType>& operator=(vtkm::Pair<FirstType, SecondType>&& src) = default;
VTKM_EXEC_CONT
bool operator==(const vtkm::Pair<FirstType, SecondType>& other) const
......@@ -141,9 +166,15 @@ VTKM_EXEC_CONT vtkm::Pair<T, U> operator+(const vtkm::Pair<T, U>& a, const vtkm:
}
template <typename T1, typename T2>
VTKM_EXEC_CONT vtkm::Pair<T1, T2> make_Pair(const T1& firstSrc, const T2& secondSrc)
VTKM_EXEC_CONT vtkm::Pair<typename std::decay<T1>::type, typename std::decay<T2>::type> make_Pair(
T1&& v1,
T2&& v2)
{
return vtkm::Pair<T1, T2>(firstSrc, secondSrc);
using DT1 = typename std::decay<T1>::type;
using DT2 = typename std::decay<T2>::type;
using PairT = vtkm::Pair<DT1, DT2>;
return PairT(std::forward<T1>(v1), std::forward<T2>(v2));
}
} // namespace vtkm
......
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