49 #ifndef KOKKOS_PAIR_HPP
50 #define KOKKOS_PAIR_HPP
52 #include <Kokkos_Macros.hpp>
64 template <
class T1,
class T2>
81 KOKKOS_DEFAULTED_FUNCTION constexpr
pair() =
default;
95 template <
class U,
class V>
103 template <
class U,
class V>
111 template <
class U,
class V>
129 template <
class U,
class V>
139 template <
class U,
class V>
156 template <
class T1,
class T2>
157 struct pair<T1&, T2&> {
159 typedef T1& first_type;
161 typedef T2& second_type;
172 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(first_type f, second_type s)
173 : first(f), second(s) {}
179 template <
class U,
class V>
180 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(
const pair<U, V>& p)
181 : first(p.first), second(p.second) {}
184 template <
class U,
class V>
185 pair(
const std::pair<U, V>& p) : first(p.first), second(p.second) {}
191 template <
class U,
class V>
192 KOKKOS_FORCEINLINE_FUNCTION pair<first_type, second_type>& operator=(
193 const pair<U, V>& p) {
208 std::pair<T1, T2> to_std_pair()
const {
213 template <
class T1,
class T2>
214 struct pair<T1, T2&> {
216 typedef T1 first_type;
218 typedef T2& second_type;
229 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(first_type
const& f, second_type s)
230 : first(f), second(s) {}
236 template <
class U,
class V>
237 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(
const pair<U, V>& p)
238 : first(p.first), second(p.second) {}
241 template <
class U,
class V>
242 pair(
const std::pair<U, V>& p) : first(p.first), second(p.second) {}
248 template <
class U,
class V>
249 KOKKOS_FORCEINLINE_FUNCTION pair<first_type, second_type>& operator=(
250 const pair<U, V>& p) {
265 std::pair<T1, T2> to_std_pair()
const {
270 template <
class T1,
class T2>
271 struct pair<T1&, T2> {
273 typedef T1& first_type;
275 typedef T2 second_type;
286 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(first_type f, second_type
const& s)
287 : first(f), second(s) {}
293 template <
class U,
class V>
294 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(
const pair<U, V>& p)
295 : first(p.first), second(p.second) {}
298 template <
class U,
class V>
299 pair(
const std::pair<U, V>& p) : first(p.first), second(p.second) {}
305 template <
class U,
class V>
306 KOKKOS_FORCEINLINE_FUNCTION pair<first_type, second_type>& operator=(
307 const pair<U, V>& p) {
322 std::pair<T1, T2> to_std_pair()
const {
328 template <
class T1,
class T2>
335 template <
class T1,
class T2>
338 return !(lhs == rhs);
342 template <
class T1,
class T2>
343 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator<(const pair<T1, T2>& lhs,
345 return lhs.
first < rhs.first ||
346 (!(rhs.first < lhs.first) && lhs.second < rhs.second);
350 template <
class T1,
class T2>
351 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator<=(const pair<T1, T2>& lhs,
357 template <
class T1,
class T2>
364 template <
class T1,
class T2>
374 template <
class T1,
class T2>
418 template <
class T1,
class T2>
428 struct pair<T1, void> {
435 KOKKOS_DEFAULTED_FUNCTION constexpr
pair() =
default;
439 KOKKOS_FORCEINLINE_FUNCTION constexpr
pair(
const first_type& f,
int)
443 KOKKOS_FORCEINLINE_FUNCTION constexpr
pair(
const pair<U, void>& p)
447 KOKKOS_FORCEINLINE_FUNCTION pair<T1, void>&
operator=(
448 const pair<U, void>& p) {
459 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator==(
460 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
461 return lhs.first == rhs.first;
465 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator!=(
466 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
467 return !(lhs == rhs);
471 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator<(
472 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
473 return lhs.first < rhs.first;
477 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator<=(
478 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
483 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator>(
484 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
489 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator>=(
490 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
497 struct is_pair_like : std::false_type {};
498 template <
class T,
class U>
499 struct is_pair_like<Kokkos::pair<T, U>> : std::true_type {};
500 template <
class T,
class U>
501 struct is_pair_like<std::pair<T, U>> : std::true_type {};
507 #endif // KOKKOS_PAIR_HPP
KOKKOS_FORCEINLINE_FUNCTION constexpr bool operator>=(const pair< T1, T2 > &lhs, const pair< T1, T2 > &rhs)
Greater-than-or-equal-to operator for Kokkos::pair.
KOKKOS_FORCEINLINE_FUNCTION constexpr pair< T1, T2 > make_pair(T1 x, T2 y)
Return a new pair.
KOKKOS_INLINE_FUNCTION bool operator==(complex< RealType1 > const &x, complex< RealType2 > const &y) noexcept
Binary == operator for complex complex.
KOKKOS_FORCEINLINE_FUNCTION constexpr pair(const volatile pair< U, V > &p)
Copy constructor.
T2 second_type
The second template parameter of this class.
Replacement for std::pair that works on CUDA devices.
KOKKOS_FORCEINLINE_FUNCTION constexpr bool operator<(const pair< T1, T2 > &lhs, const pair< T1, T2 > &rhs)
Less-than operator for Kokkos::pair.
first_type first
The first element of the pair.
KOKKOS_FORCEINLINE_FUNCTION constexpr pair(first_type const &f, second_type const &s)
Constructor that takes both elements of the pair.
T1 first_type
The first template parameter of this class.
KOKKOS_FORCEINLINE_FUNCTION constexpr bool operator<=(const pair< T1, T2 > &lhs, const pair< T1, T2 > &rhs)
Less-than-or-equal-to operator for Kokkos::pair.
KOKKOS_FORCEINLINE_FUNCTION void operator=(const volatile pair< U, V > &p) volatile
Assignment operator, for volatile *this.
KOKKOS_FORCEINLINE_FUNCTION pair< T1 &, T2 & > tie(T1 &x, T2 &y)
Return a pair of references to the input arguments.
KOKKOS_FORCEINLINE_FUNCTION constexpr bool operator>(const pair< T1, T2 > &lhs, const pair< T1, T2 > &rhs)
Greater-than operator for Kokkos::pair.
std::pair< T1, T2 > to_std_pair() const
Return the std::pair version of this object.
KOKKOS_INLINE_FUNCTION bool operator!=(complex< RealType1 > const &x, complex< RealType2 > const &y) noexcept
Binary != operator for complex complex.
KOKKOS_DEFAULTED_FUNCTION constexpr pair()=default
Default constructor.
KOKKOS_FORCEINLINE_FUNCTION constexpr pair(const pair< U, V > &p)
Copy constructor.
second_type second
The second element of the pair.
KOKKOS_FORCEINLINE_FUNCTION pair< T1, T2 > & operator=(const pair< U, V > &p)
Assignment operator.