alpaka
Abstraction Library for Parallel Kernel Acceleration
Traits.hpp
Go to the documentation of this file.
1 /* Copyright 2022 Antonio Di Pilato
2  * SPDX-License-Identifier: MPL-2.0
3  */
4 
5 #pragma once
6 
7 #include "alpaka/core/Common.hpp"
8 
9 namespace alpaka
10 {
11  //! The common trait.
12  namespace trait
13  {
14  //! The native handle trait.
15  template<typename TImpl, typename TSfinae = void>
16  struct NativeHandle
17  {
18  static auto getNativeHandle(TImpl const&)
19  {
20  static_assert(!sizeof(TImpl), "This type does not have a native handle!");
21  return 0;
22  }
23  };
24  } // namespace trait
25 
26  //! Get the native handle of the alpaka object.
27  //! It will return the alpaka object handle if there is any, otherwise it generates a compile time error.
28  template<typename TImpl>
29  ALPAKA_FN_HOST auto getNativeHandle(TImpl const& impl)
30  {
32  }
33 
34  //! Alias to the type of the native handle.
35  template<typename TImpl>
36  using NativeHandle = decltype(getNativeHandle(std::declval<TImpl>()));
37 } // namespace alpaka
#define ALPAKA_FN_HOST
Definition: Common.hpp:40
The alpaka accelerator library.
decltype(getNativeHandle(std::declval< TImpl >())) NativeHandle
Alias to the type of the native handle.
Definition: Traits.hpp:36
ALPAKA_FN_HOST auto getNativeHandle(TImpl const &impl)
Get the native handle of the alpaka object. It will return the alpaka object handle if there is any,...
Definition: Traits.hpp:29
The native handle trait.
Definition: Traits.hpp:17
static auto getNativeHandle(TImpl const &)
Definition: Traits.hpp:18