repr 0.1
Reconstructable string representations and more
Loading...
Searching...
No Matches
init_list.h
Go to the documentation of this file.
1#pragma once
2#include <string>
3#include <initializer_list>
4#include <ranges>
5#include <type_traits>
6
7#include "category.h"
8
9namespace librepr {
10template <typename T>
11struct Reflect;
12
13template <std::ranges::range T>
14 requires std::constructible_from<std::initializer_list<typename T::value_type>>
15struct Reflect<T> : category::Type<T> {
16 using type = T;
17 using element_type = typename T::value_type;
18 constexpr static bool can_descend = true;
19 constexpr static bool iterable = true;
20 constexpr static bool associative = requires {
21 typename type::key_type;
22 typename type::mapped_type;
23 };
24
25 template <typename V>
26 static void visit(V&& visitor, T& obj) {
27 for (auto&& value : obj) {
29 }
30 }
31
32 template <typename V>
33 static void visit(V&& visitor) {
35 }
36};
37} // namespace librepr
Definition ctvi/ctvi.h:9
std::string code_for()
Definition repr:39
Reflect(T &) -> Reflect< T >
T type
Definition aggregate.h:55
static void visit(V &&visitor)
Definition init_list.h:33
typename T::value_type element_type
Definition init_list.h:17
static void visit(V &&visitor, T &obj)
Definition init_list.h:26
Definition reflection/reflect.h:16
Definition category.h:49