Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/rfl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
#include "rfl/to_named_tuple.hpp"
#include "rfl/to_view.hpp"
#include "rfl/tuple_cat.hpp"
#include "rfl/type_name.hpp"
#include "rfl/type_name_t.hpp"
#include "rfl/view_t.hpp"
#include "rfl/visit.hpp"
Expand Down
27 changes: 27 additions & 0 deletions include/rfl/type_name.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef RFL_TYPE_NAME_HPP_
#define RFL_TYPE_NAME_HPP_

#include <string_view>

#include "internal/get_type_name.hpp"

namespace rfl {

/// Compile-time `std::string_view` containing the name of type `T` without
/// instantiating an `rfl::Literal` or `rfl::internal::StringLiteral`.
/// @tparam T The type whose name to retrieve
template <class T>
inline constexpr std::string_view type_name_v =
internal::get_type_name_str_view<T>();

/// Returns the compile-time name of type `T` as a `std::string_view` (usable
/// in both `constexpr` and runtime contexts).
/// @tparam T The type whose name to retrieve
template <class T>
constexpr std::string_view type_name() noexcept {
return type_name_v<T>;
}

} // namespace rfl

#endif
Loading