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>
31 #include <Kokkos_Swap.hpp>
43 template <
class T1,
class T2>
60 KOKKOS_DEFAULTED_FUNCTION constexpr
pair() =
default;
66 #if defined(KOKKOS_COMPILER_NVHPC) && KOKKOS_COMPILER_NVHPC < 230700
67 KOKKOS_FORCEINLINE_FUNCTION
69 KOKKOS_FORCEINLINE_FUNCTION constexpr
77 template <
class U,
class V>
78 #if defined(KOKKOS_COMPILER_NVHPC) && KOKKOS_COMPILER_NVHPC < 230700
79 KOKKOS_FORCEINLINE_FUNCTION
81 KOKKOS_FORCEINLINE_FUNCTION constexpr
87 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
88 template <
class U,
class V>
93 KOKKOS_DEPRECATED KOKKOS_FORCEINLINE_FUNCTION constexpr
pair(
102 template <
class U,
class V>
109 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
110 template <
class U,
class V>
122 KOKKOS_DEPRECATED KOKKOS_FORCEINLINE_FUNCTION
void operator=(
132 template <
class U,
class V>
149 template <
class T1,
class T2>
150 struct pair<T1&, T2&> {
152 using first_type = T1&;
154 using second_type = T2&;
165 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(first_type f, second_type s)
166 : first(f), second(s) {}
172 template <
class U,
class V>
173 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(
const pair<U, V>& p)
174 : first(p.first), second(p.second) {}
177 template <
class U,
class V>
178 pair(
const std::pair<U, V>& p) : first(p.first), second(p.second) {}
184 template <
class U,
class V>
185 KOKKOS_FORCEINLINE_FUNCTION pair<first_type, second_type>& operator=(
186 const pair<U, V>& p) {
201 std::pair<T1, T2> to_std_pair()
const {
202 return std::make_pair(first, second);
206 template <
class T1,
class T2>
207 struct pair<T1, T2&> {
209 using first_type = T1;
211 using second_type = T2&;
222 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(first_type
const& f, second_type s)
223 : first(f), second(s) {}
229 template <
class U,
class V>
230 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(
const pair<U, V>& p)
231 : first(p.first), second(p.second) {}
234 template <
class U,
class V>
235 pair(
const std::pair<U, V>& p) : first(p.first), second(p.second) {}
241 template <
class U,
class V>
242 KOKKOS_FORCEINLINE_FUNCTION pair<first_type, second_type>& operator=(
243 const pair<U, V>& p) {
258 std::pair<T1, T2> to_std_pair()
const {
259 return std::make_pair(first, second);
263 template <
class T1,
class T2>
264 struct pair<T1&, T2> {
266 using first_type = T1&;
268 using second_type = T2;
279 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(first_type f, second_type
const& s)
280 : first(f), second(s) {}
286 template <
class U,
class V>
287 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(
const pair<U, V>& p)
288 : first(p.first), second(p.second) {}
291 template <
class U,
class V>
292 pair(
const std::pair<U, V>& p) : first(p.first), second(p.second) {}
298 template <
class U,
class V>
299 KOKKOS_FORCEINLINE_FUNCTION pair<first_type, second_type>& operator=(
300 const pair<U, V>& p) {
315 std::pair<T1, T2> to_std_pair()
const {
316 return std::make_pair(first, second);
321 template <
class T1,
class T2>
322 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator==(
const pair<T1, T2>& lhs,
323 const pair<T1, T2>& rhs) {
324 return lhs.first == rhs.first && lhs.second == rhs.second;
328 template <
class T1,
class T2>
329 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator!=(
const pair<T1, T2>& lhs,
330 const pair<T1, T2>& rhs) {
331 return !(lhs == rhs);
335 template <
class T1,
class T2>
336 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator<(const pair<T1, T2>& lhs,
337 const pair<T1, T2>& rhs) {
338 return lhs.first < rhs.first ||
339 (!(rhs.first < lhs.first) && lhs.second < rhs.second);
343 template <
class T1,
class T2>
344 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator<=(const pair<T1, T2>& lhs,
345 const pair<T1, T2>& rhs) {
350 template <
class T1,
class T2>
351 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator>(
const pair<T1, T2>& lhs,
352 const pair<T1, T2>& rhs) {
357 template <
class T1,
class T2>
358 KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator>=(
const pair<T1, T2>& lhs,
359 const pair<T1, T2>& rhs) {
367 template <
class T1,
class T2>
368 KOKKOS_FORCEINLINE_FUNCTION constexpr pair<T1, T2> make_pair(T1 x, T2 y) {
369 return (pair<T1, T2>(x, y));
411 template <
class T1,
class T2>
412 KOKKOS_FORCEINLINE_FUNCTION pair<T1&, T2&> tie(T1& x, T2& y) {
413 return (pair<T1&, T2&>(x, y));
416 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
422 struct KOKKOS_DEPRECATED pair<T1, void> {
423 using first_type = T1;
424 using second_type = void;
429 KOKKOS_DEFAULTED_FUNCTION constexpr pair() =
default;
431 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(
const first_type& f) : first(f) {}
433 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(
const first_type& f,
int)
437 KOKKOS_FORCEINLINE_FUNCTION constexpr pair(
const pair<U, void>& p)
441 KOKKOS_FORCEINLINE_FUNCTION pair<T1, void>& operator=(
442 const pair<U, void>& p) {
452 #if defined(KOKKOS_ENABLE_DEPRECATION_WARNINGS) && \
453 defined(KOKKOS_COMPILER_GNU) && (KOKKOS_COMPILER_GNU < 1110)
454 KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_PUSH()
457 KOKKOS_DEPRECATED KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator==(
458 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
459 return lhs.first == rhs.first;
463 KOKKOS_DEPRECATED KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator!=(
464 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
465 return !(lhs == rhs);
469 KOKKOS_DEPRECATED KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator<(
470 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
471 return lhs.first < rhs.first;
475 KOKKOS_DEPRECATED KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator<=(
476 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
481 KOKKOS_DEPRECATED KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator>(
482 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
487 KOKKOS_DEPRECATED KOKKOS_FORCEINLINE_FUNCTION constexpr
bool operator>=(
488 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
491 #if defined(KOKKOS_ENABLE_DEPRECATION_WARNINGS) && \
492 defined(KOKKOS_COMPILER_GNU) && (KOKKOS_COMPILER_GNU < 1110)
493 KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_POP()
499 struct is_pair_like : std::false_type {};
500 template <
class T,
class U>
501 struct is_pair_like<Kokkos::pair<T, U>> : std::true_type {};
502 template <
class T,
class U>
503 struct is_pair_like<std::pair<T, U>> : std::true_type {};
509 #ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_PAIR
510 #undef KOKKOS_IMPL_PUBLIC_INCLUDE
511 #undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_PAIR
513 #endif // KOKKOS_PAIR_HPP
Replacement for std::pair that works on CUDA devices.
T2 second_type
The second template parameter of this class.
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.
std::pair< T1, T2 > to_std_pair() const
Return the std::pair version of this object.
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.