MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::detail::handle_traits< S, T > Struct Template Reference

How space S names T storage, with one interface for pointers and for the handles that are not (#1017, following std::mdspan's accessor policy): handle_type S::handle_type<T>, or T* const_handle_type const T* for a pointer; the handle itself otherwise (as for mdspan, constness is the accessor's business) is_pointer whether handle_type is T* offset(h, i) the handle of element i: h + i, or S::offset(h, i) address(h) the host address of the first element, in a host-accessible space: h, or S::address(h) same(a, b) whether two handles name the same storage, where that can be told: equal pointers, or equal handles of a type with ==; false for a handle without == is_null(h) whether h names no storage (nullptr, or a value-initialized handle of a type with ==). More...

#include <memory_space.hpp>

Public Types

using handle_type = space_handle_t<S, T>
using const_handle_type = std::conditional_t<is_pointer, const T*, handle_type>

Static Public Member Functions

static handle_type offset (handle_type h, std::size_t i)
static T * address (handle_type h)
static const T * address (const_handle_type h)
static bool same (const_handle_type a, const_handle_type b) noexcept
static bool is_null (const_handle_type h) noexcept

Static Public Attributes

static constexpr bool is_pointer = std::is_same_v<handle_type, T*>

Detailed Description

template<typename S, typename T>
struct mtl::detail::handle_traits< S, T >

How space S names T storage, with one interface for pointers and for the handles that are not (#1017, following std::mdspan's accessor policy): handle_type S::handle_type<T>, or T* const_handle_type const T* for a pointer; the handle itself otherwise (as for mdspan, constness is the accessor's business) is_pointer whether handle_type is T* offset(h, i) the handle of element i: h + i, or S::offset(h, i) address(h) the host address of the first element, in a host-accessible space: h, or S::address(h) same(a, b) whether two handles name the same storage, where that can be told: equal pointers, or equal handles of a type with ==; false for a handle without == is_null(h) whether h names no storage (nullptr, or a value-initialized handle of a type with ==).

Member Typedef Documentation

◆ const_handle_type

template<typename S, typename T>
using mtl::detail::handle_traits< S, T >::const_handle_type = std::conditional_t<is_pointer, const T*, handle_type>

◆ handle_type

template<typename S, typename T>
using mtl::detail::handle_traits< S, T >::handle_type = space_handle_t<S, T>

Member Function Documentation

◆ address() [1/2]

template<typename S, typename T>
const T * mtl::detail::handle_traits< S, T >::address ( const_handle_type h)
inlinestaticnodiscard

◆ address() [2/2]

template<typename S, typename T>
T * mtl::detail::handle_traits< S, T >::address ( handle_type h)
inlinestaticnodiscard

◆ is_null()

template<typename S, typename T>
bool mtl::detail::handle_traits< S, T >::is_null ( const_handle_type h)
inlinestaticnodiscardnoexcept

◆ offset()

template<typename S, typename T>
handle_type mtl::detail::handle_traits< S, T >::offset ( handle_type h,
std::size_t i )
inlinestaticnodiscard

◆ same()

template<typename S, typename T>
bool mtl::detail::handle_traits< S, T >::same ( const_handle_type a,
const_handle_type b )
inlinestaticnodiscardnoexcept

Member Data Documentation

◆ is_pointer

template<typename S, typename T>
bool mtl::detail::handle_traits< S, T >::is_pointer = std::is_same_v<handle_type, T*>
staticconstexpr

The documentation for this struct was generated from the following file: