repr 0.1
Reconstructable string representations and more
Loading...
Searching...
No Matches
util/util.h
Go to the documentation of this file.
1#pragma once
2#include <utility>
3
4namespace librepr {
5
6template <typename T>
7struct Wrap {
9};
10
11template <typename T>
13
14template <auto V, typename T = decltype(V)>
15struct Constant {
16 using value_type = T;
17 constexpr static auto value = V;
18};
19
20template <auto V>
21inline constexpr Constant<V> constant{};
22
23namespace detail {
24template <typename T>
25extern const Wrap<T> fake_obj;
26
27template <class U>
28constexpr U& convert_ref(U& ref) noexcept {
29 // https://cplusplus.github.io/LWG/issue2993
30 return ref;
31}
32
33template <class U>
34void convert_ref(U&&) = delete;
35
36template <typename From, typename To>
37concept ref_convertible_to = requires { convert_ref<To>(std::declval<From>()); };
38
39}
40
41} // namespace librepr
Definition util/util.h:37
constexpr U & convert_ref(U &ref) noexcept
Definition util/util.h:28
const Wrap< T > fake_obj
Definition ctvi/ctvi.h:9
std::string code_for()
Definition repr:39
constexpr Constant< V > constant
Definition util/util.h:21
Definition util/util.h:15
static constexpr auto value
Definition util/util.h:17
T value_type
Definition util/util.h:16
Definition util/util.h:7
T value
Definition util/util.h:8