23 #ifndef KOKKOS_PAIR_HPP
24 #define KOKKOS_PAIR_HPP
25 #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
26 #define KOKKOS_IMPL_PUBLIC_INCLUDE
27 #define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_PAIR
30 #include <Kokkos_Macros.hpp>
42 template <
class T1,
class T2>
59 KOKKOS_DEFAULTED_FUNCTION constexpr
pair() =
default;
65 #if defined(KOKKOS_COMPILER_NVHPC) && KOKKOS_COMPILER_NVHPC < 230700
66 KOKKOS_FORCEINLINE_FUNCTION
68 KOKKOS_FORCEINLINE_FUNCTION constexpr
76 template <
class U,
class V>
77 #if defined(KOKKOS_COMPILER_NVHPC) && KOKKOS_COMPILER_NVHPC < 230700
78 KOKKOS_FORCEINLINE_FUNCTION
80 KOKKOS_FORCEINLINE_FUNCTION constexpr
82 pair(
const pair<U, V>& p)
86 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
87 template <
class U,
class V>
92 KOKKOS_DEPRECATED KOKKOS_FORCEINLINE_FUNCTION constexpr
pair(
93 const volatile pair<U, V>& p)
101 template <
class U,
class V>
102 KOKKOS_FORCEINLINE_FUNCTION pair<T1, T2>&
operator=(
const pair<U, V>& p) {
108 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
109 template <
class U,
class V>
121 KOKKOS_DEPRECATED KOKKOS_FORCEINLINE_FUNCTION
void operator=(
122 const volatile pair<U, V>& p)
volatile {
131 template <
class U,
class V>
148 template <
class T1,
class T2>
149 struct pair<T1&, T2&> {
151 using first_type = T1&;
153 using second_type = T2&;
164 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(first_type f, second_type s)
165 : first(f), second(s) {}
171 template <
class U,
class V>
172 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(
const pair<U, V>& p)
173 : first(p.first), second(p.second) {}
176 template <
class U,
class V>
177 pair(
const std::pair<U, V>& p) : first(p.first), second(p.second) {}
183 template <
class U,
class V>
184 KOKKOS_FORCEINLINE_FUNCTION pair<first_type, second_type>& operator=(
185 const pair<U, V>& p) {
200 std::pair<T1, T2> to_std_pair()
const {
201 return std::make_pair(first, second);
205 template <
class T1,
class T2>
206 struct pair<T1, T2&> {
208 using first_type = T1;
210 using second_type = T2&;
221 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(first_type
const& f, second_type s)
222 : first(f), second(s) {}
228 template <
class U,
class V>
229 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(
const pair<U, V>& p)
230 : first(p.first), second(p.second) {}
233 template <
class U,
class V>
234 pair(
const std::pair<U, V>& p) : first(p.first), second(p.second) {}
240 template <
class U,
class V>
241 KOKKOS_FORCEINLINE_FUNCTION pair<first_type, second_type>& operator=(
242 const pair<U, V>& p) {
257 std::pair<T1, T2> to_std_pair()
const {
258 return std::make_pair(first, second);
262 template <
class T1,
class T2>
263 struct pair<T1&, T2> {
265 using first_type = T1&;
267 using second_type = T2;
278 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(first_type f, second_type
const& s)
279 : first(f), second(s) {}
285 template <
class U,
class V>
286 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(
const pair<U, V>& p)
287 : first(p.first), second(p.second) {}
290 template <
class U,
class V>
291 pair(
const std::pair<U, V>& p) : first(p.first), second(p.second) {}
297 template <
class U,
class V>
298 KOKKOS_FORCEINLINE_FUNCTION pair<first_type, second_type>& operator=(
299 const pair<U, V>& p) {
314 std::pair<T1, T2> to_std_pair()
const {
315 return std::make_pair(first, second);
320 template <
class T1,
class T2>
321 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator==(
const pair<T1, T2>& lhs,
322 const pair<T1, T2>& rhs) {
323 return lhs.first == rhs.first && lhs.second == rhs.second;
327 template <
class T1,
class T2>
328 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator!=(
const pair<T1, T2>& lhs,
329 const pair<T1, T2>& rhs) {
330 return !(lhs == rhs);
334 template <
class T1,
class T2>
335 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator<(const pair<T1, T2>& lhs,
336 const pair<T1, T2>& rhs) {
337 return lhs.first < rhs.first ||
338 (!(rhs.first < lhs.first) && lhs.second < rhs.second);
342 template <
class T1,
class T2>
343 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator<=(const pair<T1, T2>& lhs,
344 const pair<T1, T2>& rhs) {
349 template <
class T1,
class T2>
350 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator>(
const pair<T1, T2>& lhs,
351 const pair<T1, T2>& rhs) {
356 template <
class T1,
class T2>
357 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator>=(
const pair<T1, T2>& lhs,
358 const pair<T1, T2>& rhs) {
366 template <
class T1,
class T2>
367 KOKKOS_FORCEINLINE_FUNCTION constexpr pair<T1, T2> make_pair(T1 x, T2 y) {
368 return (pair<T1, T2>(x, y));
410 template <
class T1,
class T2>
411 KOKKOS_FORCEINLINE_FUNCTION pair<T1&, T2&> tie(T1& x, T2& y) {
412 return (pair<T1&, T2&>(x, y));
420 struct pair<T1, void> {
427 KOKKOS_DEFAULTED_FUNCTION constexpr
pair() =
default;
431 KOKKOS_FORCEINLINE_FUNCTION constexpr
pair(
const first_type& f,
int)
435 KOKKOS_FORCEINLINE_FUNCTION constexpr
pair(
const pair<U, void>& p)
439 KOKKOS_FORCEINLINE_FUNCTION pair<T1, void>&
operator=(
440 const pair<U, void>& p) {
451 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator==(
452 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
453 return lhs.first == rhs.first;
457 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator!=(
458 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
459 return !(lhs == rhs);
463 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator<(
464 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
465 return lhs.first < rhs.first;
469 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator<=(
470 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
475 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator>(
476 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
481 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator>=(
482 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
489 struct is_pair_like : std::false_type {};
490 template <
class T,
class U>
491 struct is_pair_like<Kokkos::pair<T, U>> : std::true_type {};
492 template <
class T,
class U>
493 struct is_pair_like<std::pair<T, U>> : std::true_type {};
499 #ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_PAIR
500 #undef KOKKOS_IMPL_PUBLIC_INCLUDE
501 #undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_PAIR
503 #endif // KOKKOS_PAIR_HPP
first_type first
The first element of the pair.
std::pair< T1, T2 > to_std_pair() const
KOKKOS_DEFAULTED_FUNCTION constexpr pair()=default
second_type second
The second element of the pair.
KOKKOS_FORCEINLINE_FUNCTION pair< T1, T2 > & operator=(const pair< U, V > &p)