17#ifndef KOKKOS_TYPE_INFO_HPP
18#define KOKKOS_TYPE_INFO_HPP
24#include <Kokkos_Macros.hpp>
28#if (!defined(KOKKOS_COMPILER_NVCC) || (KOKKOS_COMPILER_NVCC >= 1130)) && \
29 (!(defined(KOKKOS_COMPILER_NVCC) && defined(KOKKOS_COMPILER_MSVC)))
31#define KOKKOS_ENABLE_IMPL_TYPEINFO
36constexpr std::array<char, N> to_array(std::string_view src) {
37 std::array<char, N> dst{};
38 for (
size_t i = 0; i < N; ++i) {
45constexpr auto type_name() {
47 constexpr std::string_view func = __PRETTY_FUNCTION__;
48 constexpr std::string_view prefix{
"[T = "};
49 constexpr std::string_view suffix{
"]"};
50#elif defined(__GNUC__)
51 constexpr std::string_view func = __PRETTY_FUNCTION__;
52 constexpr std::string_view prefix{
"[with T = "};
53 constexpr std::string_view suffix{
"]"};
54#elif defined(_MSC_VER)
55 constexpr std::string_view func = __FUNCSIG__;
56 constexpr std::string_view prefix{
"type_name<"};
57 constexpr std::string_view suffix{
">(void)"};
61 constexpr auto beg = func.find(prefix) + prefix.
size();
62 constexpr auto end = func.rfind(suffix);
63 static_assert(beg != std::string_view::npos);
64 static_assert(end != std::string_view::npos);
65 return to_array<end - beg>(func.substr(beg, end));
70 static constexpr auto value_ = type_name<T>();
73 static constexpr std::string_view name() noexcept {
74 return {value_.data(), value_.size()};
87 static constexpr std::string_view name() noexcept {
return "not supported"; }
KOKKOS_FORCEINLINE_FUNCTION unsigned size() const
ScopeGuard Some user scope issues have been identified with some Kokkos::finalize calls; ScopeGuard a...