repr 0.1
Reconstructable string representations and more
Loading...
Searching...
No Matches
repr
Go to the documentation of this file.
1#pragma once
2#include <string>
3
5#include <librepr/type_info.h>
6#include <librepr/visit.h>
11
12namespace librepr {
22 template <typename T>
23 std::string operator()(T const& obj, Options options = {}) const {
24 // TODO this could be static once msvc supports it
25 auto visitor = ReprVisitor{options};
27 return visitor.result.extract();
28 }
29};
30
31enum class Language { CPP, Python };
32
38template <typename T, Language language = Language::CPP>
40 if constexpr (language == Language::Python) {
43 return visitor.result.extract();
44 }
47 return visitor.result.extract();
48}
49
50template <typename T>
54 return visitor.result.extract();
55}
56} // namespace librepr
57
58inline constexpr ::librepr::ReprWrapper
59 repr{};
61template <typename T>
62inline constexpr ::librepr::TypeName<T> nameof{};
Definition repr.h:20
Definition ctvi/ctvi.h:9
std::string code_for()
Definition repr:39
std::string layout_of()
Definition repr:51
Language
Definition repr:31
void visit(V &&visitor)
Definition visit.h:9
constexpr ::librepr::ReprWrapper repr
Definition repr:59
constexpr ::librepr::TypeName< T > nameof
Definition repr:62
Definition cpp.h:17
Definition layout.h:9
Definition options.h:7
Definition python.h:26
Definition repr:15
std::string operator()(T const &obj, Options options={}) const
Definition repr:23