File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #ifndef RFL_INTERNAL_CPP26_GETTYPENAME_HPP_
2+ #define RFL_INTERNAL_CPP26_GETTYPENAME_HPP_
3+
4+ #include < meta>
5+ #include < type_traits>
6+
7+ #include " ../StringLiteral.hpp"
8+
9+ namespace rfl ::internal::cpp26 {
10+
11+ template <class T >
12+ consteval auto get_type_name () {
13+ using Type = std::remove_cvref_t <T>;
14+ if constexpr (std::is_pointer_v<Type>) {
15+ return get_type_name<std::remove_pointer_t <Type>>();
16+ } else {
17+ // TODO: Is there a way to get the name of the type without using
18+ // compiler-specific extensions?
19+ #if defined(__GNUC__)
20+ constexpr auto display_string = std::meta::display_string_of (^^Type);
21+ constexpr auto drop_last_char =
22+ display_string.substr (0 , display_string.size () - 1 );
23+ constexpr auto name =
24+ drop_last_char.substr (drop_last_char.find (" {aka " ) + 5 );
25+ return StringLiteral<name.size () + 1 >(name);
26+ #else
27+ static_assert (false ,
28+ " You are using an unsupported compiler. Please use GCC or "
29+ " explicitly tag your structs using 'Tag' or 'Name'." );
30+ #endif
31+ }
32+ }
33+ } // namespace rfl::internal::cpp26
34+
35+ #endif
Original file line number Diff line number Diff line change 11#ifndef RFL_INTERNAL_GETTYPENAME_HPP_
22#define RFL_INTERNAL_GETTYPENAME_HPP_
3- // TODO
4- // #ifndef REFLECTCPP_USE_CPP26_REFLECTION
3+
4+ #ifndef REFLECTCPP_USE_CPP26_REFLECTION
55#include " cpp20/get_type_name.hpp"
6- // #else
7- // TODO
8- // #endif
6+ #else
7+ # include " cpp26/get_type_name.hpp "
8+ #endif
99
1010namespace rfl ::internal {
1111
1212template <class T >
1313consteval auto get_type_name () {
14- // #ifndef REFLECTCPP_USE_CPP26_REFLECTION
14+ #ifndef REFLECTCPP_USE_CPP26_REFLECTION
1515 return cpp20::get_type_name<T>();
16- // #else
17- // TODO
18- // #endif
16+ #else
17+ return cpp26::get_type_name<T>();
18+ #endif
1919}
2020
2121} // namespace rfl::internal
You can’t perform that action at this time.
0 commit comments