repr
0.1
Reconstructable string representations and more
Loading...
Searching...
No Matches
repr/enum.h
Go to the documentation of this file.
1
#pragma once
2
#include <
string
>
3
#include <
type_traits
>
4
5
#include <
librepr/feature.h
>
6
#include <
librepr/enum/reflect.h
>
7
#include <
librepr/macro/default.h
>
8
9
#if USING(REPR_USE_MAGIC_ENUM)
10
#include <
librepr/name/type.h
>
11
#endif
12
13
14
namespace
librepr
{
15
template
<
typename
T>
16
requires
std::is_enum_v<T>
17
std::string
repr
(T
const
&
obj
) {
18
auto
name =
librepr::enum_name
(
obj
);
19
20
// TODO handle compound flags
21
if
(!name.empty()) {
22
#if USING(REPR_USE_MAGIC_ENUM)
23
if
constexpr
(
detail::is_scoped_enum<T>
) {
24
return
librepr::get_name<T>
() +
"::"
+
std::string
{name};
25
}
26
#endif
27
return
std::string
{name};
28
}
29
30
return
librepr::repr
(
static_cast<
std::underlying_type_t<T>
>
(
obj
));
31
}
32
}
// namespace librepr
std::string
librepr::detail::is_scoped_enum
Definition
concepts.h:21
default.h
reflect.h
feature.h
librepr
Definition
ctvi/ctvi.h:9
librepr::repr
std::string repr(T const &obj)
Definition
repr/enum.h:17
librepr::code_for
std::string code_for()
Definition
repr:39
librepr::enum_name
constexpr std::string_view enum_name() noexcept
Definition
enum/reflect.h:45
repr
constexpr ::librepr::ReprWrapper repr
Definition
repr:59
string
type.h
type_traits
std::underlying_type_t
include
librepr
repr
enum.h
Generated by
1.9.8, using the excellent
Doxygen Awesome
Theme