cuda-kat
CUDA kernel author's tools
Classes | Macros | Functions
utility.hpp File Reference

An adaptation for host-and-device use of some of the standard C++ library's <utility> code. More...

#include <kat/common.hpp>
#include <type_traits>
#include <utility>
#include <kat/detail/integer_sequence.hpp>

Go to the source code of this file.

Classes

struct  kat::detail::addr_impl_ref< T >
 
struct  kat::detail::addressof_impl< T >
 

Functions

template<typename T >
KAT_FHD CONSTEXPR_SINCE_CPP_14 void kat::swap (T &a, T &b) noexcept(std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value)
 Swap two values on the device-side, in-place. More...
 
template<class T >
const KAT_FHD T * kat::addressof (const T &&)=delete
 
template<class T >
KAT_FHD T * kat::addressof (T &v)
 Obtains the actual address of the object or function arg, even in presence of overloaded operator&() More...
 

Detailed Description

An adaptation for host-and-device use of some of the standard C++ library's <utility> code.

Function Documentation

§ addressof()

template<class T >
KAT_FHD T* kat::addressof ( T &  v)

Obtains the actual address of the object or function arg, even in presence of overloaded operator&()

Note
In the standard library, this function is somehow in <memory>.

§ swap()

template<typename T >
KAT_FHD CONSTEXPR_SINCE_CPP_14 void kat::swap ( T &  a,
T &  b 
)
noexcept

Swap two values on the device-side, in-place.

Note
A (CUDA, or any other) compiler will often not actually emit any code when this function is used. Instead, it will use one argument instead of the other in later code, i.e. "swap" them in its own internal figuring.
Is this enough, without the multiple specializations for std::swap?
Todo:
How does EASTL swap work? Should I incorporate its specializations?
Note
Some kat types overload this default implementation.