repr 0.1
Reconstructable string representations and more
Loading...
Searching...
No Matches
to_tuple.h
Go to the documentation of this file.
1#pragma once
2#include <memory>
3#include <type_traits>
4
6#include "visit_aggregate.h"
7
8namespace librepr::detail {
9
10template <typename T>
11 requires(std::is_aggregate_v<std::remove_cvref_t<T>> && !std::is_array_v<std::remove_cvref_t<T>>)
12constexpr auto to_tuple(T&& object) {
13 return visit_aggregate([]<typename... Ts>(Ts&&... members){
14 return librepr::Tuple<Ts...>{std::forward<Ts>(members)...};
15 }, std::forward<T>(object));
16}
17
18template <typename T>
19 requires(std::is_aggregate_v<std::remove_cvref_t<T>> && !std::is_array_v<std::remove_cvref_t<T>>)
20constexpr auto to_addr_tuple(T&& object) {
21 return visit_aggregate([]<typename... Ts>(Ts&&... members){
23 }, std::forward<T>(object));
24}
25}
T addressof(T... args)
Definition assert.h:89
constexpr auto visit_aggregate(V &&visitor, T &&object)
Definition visit_aggregate.h:10
constexpr auto to_tuple(T &&object)
Definition to_tuple.h:12
constexpr auto to_addr_tuple(T &&object)
Definition to_tuple.h:20
std::string code_for()
Definition repr:39
Definition tuple.h:37