![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/include/boost/hana/experimental/ |
Upload File : |
/* @file Defines `boost::hana::experimental::type_name`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_EXPERIMENTAL_TYPE_NAME_HPP #define BOOST_HANA_EXPERIMENTAL_TYPE_NAME_HPP #include <boost/hana/config.hpp> #include <boost/hana/string.hpp> #include <cstddef> #include <utility> BOOST_HANA_NAMESPACE_BEGIN namespace experimental { namespace detail { struct cstring { char const* ptr; std::size_t length; }; // Note: We substract the null terminator from the string sizes below. template <typename T> constexpr cstring type_name_impl2() { #if defined(__clang__) constexpr char const* pretty_function = __PRETTY_FUNCTION__; constexpr std::size_t total_size = sizeof(__PRETTY_FUNCTION__) - 1; constexpr std::size_t prefix_size = sizeof("boost::hana::experimental::detail::cstring boost::hana::experimental::detail::type_name_impl2() [T = ") - 1; constexpr std::size_t suffix_size = sizeof("]") - 1; #else #error "No support for this compiler." #endif return {pretty_function + prefix_size, total_size - prefix_size - suffix_size}; } template <typename T, std::size_t ...i> auto type_name_impl1(std::index_sequence<i...>) { constexpr auto name = detail::type_name_impl2<T>(); return hana::string<*(name.ptr + i)...>{}; } } // end namespace detail //! @ingroup group-experimental //! Returns a `hana::string` representing the name of the given type, at //! compile-time. //! //! This only works on Clang (and apparently MSVC, but Hana does not work //! there as of writing this). Original idea taken from //! https://github.com/Manu343726/ctti. template <typename T> auto type_name() { constexpr auto name = detail::type_name_impl2<T>(); return detail::type_name_impl1<T>(std::make_index_sequence<name.length>{}); } } BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_EXPERIMENTAL_TYPE_NAME_HPP