49#ifndef KOKKOS_PAIR_HPP
50#define KOKKOS_PAIR_HPP
52#include <Kokkos_Macros.hpp>
64template <
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>
156template <
class T1,
class T2>
157struct pair<T1&, T2&> {
159 using first_type = T1&;
161 using second_type = T2&;
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 {
209 return std::make_pair(first, second);
213template <
class T1,
class T2>
214struct pair<T1, T2&> {
216 using first_type = T1;
218 using second_type = T2&;
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 {
266 return std::make_pair(first, second);
270template <
class T1,
class T2>
271struct pair<T1&, T2> {
273 using first_type = T1&;
275 using second_type = T2;
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 {
323 return std::make_pair(first, second);
328template <
class T1,
class T2>
335template <
class T1,
class T2>
336KOKKOS_FORCEINLINE_FUNCTION
constexpr bool operator!=(
const pair<T1, T2>& lhs,
338 return !(lhs == rhs);
342template <
class T1,
class T2>
350template <
class T1,
class T2>
357template <
class T1,
class T2>
364template <
class T1,
class T2>
374template <
class T1,
class T2>
418template <
class T1,
class T2>
428struct 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) {
459KOKKOS_FORCEINLINE_FUNCTION
constexpr bool operator==(
460 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
461 return lhs.first == rhs.first;
465KOKKOS_FORCEINLINE_FUNCTION
constexpr bool operator!=(
466 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
467 return !(lhs == rhs);
471KOKKOS_FORCEINLINE_FUNCTION
constexpr bool operator<(
472 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
473 return lhs.first < rhs.first;
477KOKKOS_FORCEINLINE_FUNCTION
constexpr bool operator<=(
478 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
483KOKKOS_FORCEINLINE_FUNCTION
constexpr bool operator>(
484 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
489KOKKOS_FORCEINLINE_FUNCTION
constexpr bool operator>=(
490 const pair<T1, void>& lhs,
const pair<T1, void>& rhs) {
497struct is_pair_like : std::false_type {};
498template <
class T,
class U>
499struct is_pair_like<Kokkos::pair<T, U>> : std::true_type {};
500template <
class T,
class U>
501struct is_pair_like<std::pair<T, U>> : std::true_type {};
KOKKOS_FORCEINLINE_FUNCTION pair< T1 &, T2 & > tie(T1 &x, T2 &y)
Return a pair of references to the input arguments.
KOKKOS_FORCEINLINE_FUNCTION constexpr pair< T1, T2 > make_pair(T1 x, T2 y)
Return a new pair.
KOKKOS_FORCEINLINE_FUNCTION constexpr bool operator<(const pair< T1, T2 > &lhs, const pair< T1, T2 > &rhs)
Less-than operator for Kokkos::pair.
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 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 bool operator>(const pair< T1, T2 > &lhs, const pair< T1, T2 > &rhs)
Greater-than operator for Kokkos::pair.
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 pair< T1, T2 > & operator=(const pair< U, V > &p)
Assignment operator.
KOKKOS_FORCEINLINE_FUNCTION constexpr pair(first_type const &f, second_type const &s)
Constructor that takes both elements of the pair.
KOKKOS_FORCEINLINE_FUNCTION constexpr pair(const pair< U, V > &p)
Copy constructor.
std::pair< T1, T2 > to_std_pair() const
Return the std::pair version of this object.
KOKKOS_FORCEINLINE_FUNCTION constexpr pair(const volatile pair< U, V > &p)
Copy constructor.
KOKKOS_FORCEINLINE_FUNCTION void operator=(const volatile pair< U, V > &p) volatile
Assignment operator, for volatile *this.
second_type second
The second element of the pair.
KOKKOS_DEFAULTED_FUNCTION constexpr pair()=default
Default constructor.
T1 first_type
The first template parameter of this class.