repr 0.1
Reconstructable string representations and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
repr/enum.h
Go to the documentation of this file.
#pragma once
#include <string>
#include <type_traits>
#if USING(REPR_USE_MAGIC_ENUM)
#endif
namespace librepr {
template <typename T>
requires std::is_enum_v<T>
std::string repr(T const& obj) {
auto name = librepr::enum_name(obj);
// TODO handle compound flags
if (!name.empty()) {
#if USING(REPR_USE_MAGIC_ENUM)
if constexpr (detail::is_scoped_enum<T>) {
return librepr::get_name<T>() + "::" + std::string{name};
}
#endif
return std::string{name};
}
}
} // namespace librepr