repr 0.1
Reconstructable string representations and more
Loading...
Searching...
No Matches
array.h
Go to the documentation of this file.
1#pragma once
2#include <cstddef>
3#include <concepts>
4#include <string>
5#include <type_traits>
6#include "category.h"
7
8namespace librepr {
9
10template <typename T>
11struct Reflect;
12
13template <typename T, std::size_t N>
14 requires(not std::same_as<std::remove_reference_t<T>, char const>) // TODO exclude other string literals
15struct Reflect<T[N]> : category::Type<T[N]> {
16 using type = T[N];
17 using element_type = T;
18
19 constexpr static auto extent = N;
20 constexpr static bool can_descend = true;
21 constexpr static bool iterable = true;
22
23 template <typename V>
24 static void visit(V&& visitor, T (&obj)[N]) {
25 for (std::size_t idx = 0; idx < N; ++idx) {
27 }
28 }
29
30 template <typename V>
31 static void visit(V&& visitor) {
33 }
34};
35
36template <typename T>
37struct Reflect<T[]> : category::Type<T[]> { // NOLINT
38 using type = T[];
39 using element_type = T;
40 constexpr static bool can_descend = true;
41 constexpr static bool iterable = true;
42
43 template <typename V>
44 static void visit(V&& /* visitor */, T const& /* obj */) { }
45
46 template <typename V>
47 static void visit(V&& /* visitor */) { }
48};
49
50} // namespace librepr
Definition ctvi/ctvi.h:9
std::string code_for()
Definition repr:39
Reflect(T &) -> Reflect< T >
T element_type
Definition array.h:17
T[N] type
Definition array.h:16
static void visit(V &&visitor)
Definition array.h:31
static void visit(V &&visitor, T(&obj)[N])
Definition array.h:24
T element_type
Definition array.h:39
static void visit(V &&, T const &)
Definition array.h:44
T[] type
Definition array.h:38
static void visit(V &&)
Definition array.h:47
Definition reflection/reflect.h:16
Definition category.h:82
Definition category.h:49