draconisplusplus/include/rfl/internal/remove_namespaces.hpp

29 lines
808 B
C++
Raw Normal View History

2024-05-31 22:59:00 -04:00
#ifndef RFL_INTERNAL_REMOVE_NAMESPACES_HPP_
#define RFL_INTERNAL_REMOVE_NAMESPACES_HPP_
#include <source_location>
#include <string_view>
#include <utility>
#include "StringLiteral.hpp"
namespace rfl {
2024-06-08 14:10:59 -04:00
namespace internal {
2024-05-31 22:59:00 -04:00
2024-06-08 14:10:59 -04:00
template <StringLiteral _name>
consteval auto remove_namespaces() {
constexpr auto name = _name.string_view();
constexpr size_t pos = name.find_last_of(":");
if constexpr (pos == std::string_view::npos) { return _name; }
constexpr auto substr = name.substr(pos + 1);
const auto to_str_lit = [&]<auto... Ns>(std::index_sequence<Ns...>) {
return StringLiteral<sizeof...(Ns) + 1> {substr[Ns]...};
};
return to_str_lit(std::make_index_sequence<substr.size()> {});
}
2024-05-31 22:59:00 -04:00
2024-06-08 14:10:59 -04:00
} // namespace internal
} // namespace rfl
2024-05-31 22:59:00 -04:00
#endif