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
aggregate.h
Go to the documentation of this file.
#pragma once
#include <
cstddef
>
#include <
string
>
#include <
string_view
>
#include <
type_traits
>
#include <
librepr/util/collections/list.h
>
#include <
librepr/util/collections/reftuple.h
>
#include <
librepr/util/concepts.h
>
#include <
librepr/name/member.h
>
// TODO
#include <
librepr/customization.h
>
#include <
librepr/customization/reflection.h
>
#include "
category.h
"
#include "
detail/arity.h
"
#include "
detail/to_reftuple.h
"
namespace
librepr
{
template
<
typename
T>
concept
reflect_names
=
requires
{
requires
librepr::Settings<T>::aggregate_member_names
; };
template
<
typename
T>
struct
Reflect
;
namespace
category {
template
<
typename
Member,
typename
Parent, std::
size_t
Index>
struct
DataMember
:
Member
{
using
descend
=
Member
;
using
type
=
typename
Member::type
;
using
parent
=
Parent
;
using
parent_type
=
typename
Parent::type;
[[
nodiscard
]]
std::string_view
name
()
const
{
return
member_name<parent_type, Index>
;
}
[[
nodiscard
]]
std::string_view
name
()
const
{
…
}
using
Member::visit;
};
struct
DataMember
:
Member
{
…
};
}
// namespace category
namespace
category {
…
}
template
<
typename
T>
requires
(std::is_aggregate_v<T> && !(std::is_array_v<T> ||
has_custom_members<T>
|| detail::has_repr_member<T>))
struct
Reflect
<T> :
category::Type
<T> {
constexpr
static
auto
member_count = librepr::detail::arity<T>;
using
member_tuple
=
decltype
(
librepr::detail::to_reftuple
(std::declval<T>()));
static_assert
(!std::is_same_v<member_tuple, void>,
"Aggregate reflection failed"
);
using
member_types
=
typename
pack::rebox<member_tuple, TypeList>::template
map<std::remove_reference_t>
;
using
type
= T;
using
members
=
typename
member_types::template
map<librepr::Reflect>
;
constexpr
static
bool
can_descend =
true
;
template
<
typename
V>
static
void
visit
(V&&
visitor
, T&
obj
) {
auto
decomposed
=
librepr::detail::to_reftuple
(
obj
);
static_assert
(members::size ==
decltype
(
decomposed
)::size,
"Decomposed obj does not match reflected member amount."
);
members::enumerate([&
visitor
, &
decomposed
]<
typename
M
,
std::size_t
Index
> {
visitor
(
category::Value
<
category::DataMember<M, Reflect, Index>
>{
librepr::get<Index>
(
decomposed
)});
});
}
static
void
visit
(V&&
visitor
, T&
obj
) {
…
}
template
<
typename
V>
static
void
visit
(V&&
visitor
) {
members::enumerate(
[&
visitor
]<
typename
M
,
std::size_t
Index
> {
visitor
(
category::DataMember<M, Reflect, Index>
{}); });
}
static
void
visit
(V&&
visitor
) {
…
}
};
struct
Reflect
<T> :
category::Type
<T> {
…
};
}
// namespace librepr
include
librepr
reflection
aggregate.h
Generated by
1.9.8, using the excellent
Doxygen Awesome
Theme