diff --git a/cudax/include/cuda/experimental/__stf/utility/traits.cuh b/cudax/include/cuda/experimental/__stf/utility/traits.cuh index 0d1dfb2a521..821921b9653 100644 --- a/cudax/include/cuda/experimental/__stf/utility/traits.cuh +++ b/cudax/include/cuda/experimental/__stf/utility/traits.cuh @@ -26,6 +26,7 @@ #endif // no system header #include +#include #include #include @@ -37,62 +38,19 @@ namespace cuda::experimental::stf { -namespace reserved -{ -// We use this function as a detector for what __PRETTY_FUNCTION__ looks like -template -constexpr ::std::string_view type_name_IMPL() -{ -#if _CCCL_COMPILER(MSVC) - return __FUNCSIG__; -#else // ^^^ _CCCL_COMPILER(MSVC) ^^^ / vvv !_CCCL_COMPILER(MSVC) vvv - return __PRETTY_FUNCTION__; -#endif // !_CCCL_COMPILER(MSVC) -} - -// Length of prefix and suffix in __PRETTY_FUNCTION__ when used with `type_name`. -inline constexpr ::std::pair type_name_affixes = [] { - const auto p = type_name_IMPL(); - const auto target = ::std::string_view("double"); - const auto len = target.size(); - // Simulate p.find() by hand because clang can't do it. - size_t i = target.npos; - for (std::size_t start = 0; start <= p.size() - len; ++start) - { - if (p.substr(start, len) == target) - { - i = start; // Found the substring, set i to the starting position - break; // Exit loop after finding the first match - } - } - auto j = p.size() - i - len; - return ::std::pair{i, j}; -}(); - -template -constexpr ::std::string_view type_name_impl() -{ -#if _CCCL_COMPILER(MSVC) - constexpr ::std::string_view p = __FUNCSIG__; - // MSVC does not provide constexpr methods so we make this utility much simpler and return __FUNCSIG__ directly - return p; -#else // ^^^ _CCCL_COMPILER(MSVC) ^^^ / vvv !_CCCL_COMPILER(MSVC) vvv - ::std::string_view p = __PRETTY_FUNCTION__; - return p.substr(type_name_affixes.first, p.size() - type_name_affixes.first - type_name_affixes.second); -#endif // !_CCCL_COMPILER(MSVC) -} -} // namespace reserved - /** * @brief Yields a string form of type name. Exact spelling not guaranteed (e.g. `type_name` may be `"int*"`, * `"int *"` etc). * + * Thin wrapper around `cuda::std::__pretty_nameof()` returning `::std::string_view`. + * * @tparam T The type to show. * * @snippet unittest.h type_name */ template -inline constexpr ::std::string_view type_name = reserved::type_name_impl(); +inline const ::std::string_view type_name{ + ::cuda::std::__pretty_nameof().data(), ::cuda::std::__pretty_nameof().size()}; /** * @brief Converts each element in `t` to a new value by calling `f`, then returns a tuple collecting the values thus