repr
0.1
Reconstructable string representations and more
Toggle main menu visibility
Main Page
Installation
Usage
Customization
Extending
FAQ
CI Results
Test
Benchmark
API Documentation
Namespace List
Namespace List
Namespace Members
All
_
a
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
v
w
Functions
_
a
c
d
e
f
g
i
l
m
n
o
r
s
t
u
v
w
Variables
Typedefs
Enumerations
Concept List
Class List
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Functions
_
a
c
e
f
g
i
l
m
n
o
p
r
s
t
v
w
~
Variables
a
b
c
d
e
f
g
i
k
l
m
n
o
p
q
r
s
t
u
v
Typedefs
a
c
d
e
f
g
h
l
m
p
r
s
t
u
v
w
Enumerations
Enumerator
Related Symbols
File List
File List
File Members
All
_
l
n
o
r
u
Variables
Macros
_
l
o
r
u
Examples
Source Code
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Concepts
Loading...
Searching...
No Matches
category.h
Go to the documentation of this file.
#pragma once
#include <
concepts
>
#include <
cstddef
>
#include <
string_view
>
#include <
type_traits
>
#include <
utility
>
#include <
librepr/macro/util.h
>
#include <
librepr/name/type.h
>
#include <
librepr/util/util.h
>
namespace
librepr
{
template
<
typename
T>
struct
Reflect
;
}
namespace
librepr::category
{
template
<
typename
T>
concept
has_name
=
requires
(T
obj
) {
std::string_view
{
obj
.name()}; };
template
<
typename
T>
concept
has_parent
=
requires
{
typename
T::parent; };
template
<
typename
T>
concept
has_members
=
requires
{
typename
T::members; };
template
<
typename
T>
concept
has_extent
=
requires
{
{ T::extent } -> std::convertible_to<std::size_t>;
};
concept
has_extent
=
requires
{
…
}
template
<
typename
T>
concept
has_alternatives
=
requires
{
typename
T::alternatives; };
template
<
typename
T>
concept
has_enumerator_names
=
requires
{ T::enumerator_names; };
template
<
typename
T>
concept
has_value
=
requires
(T
obj
) {
obj
.value(); };
template
<
typename
T>
concept
can_descend
=
has_members<T>
||
has_extent<T>
||
has_alternatives<T>
|| T::can_descend;
template
<
typename
T>
concept
is_iterable
= T::is_iterable;
template
<
class
T>
struct
Value
: T {
// essentially a std::reference_wrapper without operator()
using
descend
= T;
using
type
=
typename
T::type;
template
<detail::ref_convertible_to<type> U>
requires
(!std::same_as<Value, std::remove_cvref_t<U>>)
constexpr
explicit
(
false
)
Value
(
U
&&
obj
)
noexcept
(
noexcept
(detail::convert_ref<type>(std::forward<U>(
obj
))))
: data(
std::addressof
(detail::convert_ref<type>(std::forward<U>(
obj
)))) {}
constexpr
explicit
(
false
)
Value
(
U
&&
obj
)
noexcept
(
noexcept
(detail::convert_ref<type>(std::forward<U>(
obj
)))) {
…
}
Value
(
const
Value
&)
noexcept
=
default
;
Value
&
operator=
(
const
Value
&)
noexcept
=
default
;
~Value
() =
default
;
constexpr
explicit
(
false
)
operator
type
&()
const
noexcept
{
return
*data; }
constexpr
type
&
operator*
()
const
noexcept
{
return
*data; }
constexpr
type
*
operator->
()
const
noexcept
{
return
data; }
[[
nodiscard
]]
constexpr
type
&
value
()
const
noexcept
{
return
*data; }
template
<
typename
V>
void
visit
(V&&
visitor
) {
LIBREPR_MAYBE_DO
(T::visit(std::forward<V>(
visitor
),
value
()));
}
void
visit
(V&&
visitor
) {
…
}
private
:
type
* data;
};
struct
Value
: T {
…
};
template
<
class
T>
Value
(T&) ->
Value<Reflect<T>
>;
template
<
typename
T>
struct
Type
{
using
type
= T;
[[
nodiscard
]]
static
auto
type_name
() {
return
librepr::get_name<type>
(); }
template
<
typename
V>
static
void
visit
(V&&
visitor
) {
LIBREPR_MAYBE_DO
(
Reflect<T>::visit
(std::forward<V>(
visitor
)));
}
static
void
visit
(V&&
visitor
) {
…
}
};
struct
Type
{
…
};
}
// namespace librepr::category
include
librepr
reflection
category.h
Generated by
1.9.8, using the excellent
Doxygen Awesome
Theme