Iros
 
Loading...
Searching...
No Matches
add_member_get.h
Go to the documentation of this file.
1#pragma once
2
3#include "di/types/size_t.h"
4#include "di/util/get.h"
5#include "di/util/move.h"
7
8namespace di::util {
9template<typename Self>
11private:
12 constexpr auto self() & -> Self& { return static_cast<Self&>(*this); }
13 constexpr auto self() const& -> Self const& { return static_cast<Self const&>(*this); }
14 constexpr auto self() && -> Self&& { return static_cast<Self&&>(*this); }
15 constexpr auto self() const&& -> Self const&& { return static_cast<Self const&&>(*this); }
16
17public:
18 template<types::size_t index>
19 requires(requires(Self& self) { util::get<index>(self); })
20 constexpr auto get() & -> decltype(auto) {
21 return util::get<index>(self());
22 }
23
24 template<types::size_t index>
25 requires(requires(Self const& self) { util::get<index>(self); })
26 constexpr auto get() const& -> decltype(auto) {
27 return util::get<index>(self());
28 }
29
30 template<types::size_t index>
31 requires(requires(Self&& self) { util::get<index>(util::move(self)); })
32 constexpr auto get() && -> decltype(auto) {
33 return util::get<index>(util::move(*this).self());
34 }
35
36 template<types::size_t index>
37 requires(requires(Self const&& self) { util::get<index>(util::move(self)); })
38 constexpr auto get() const&& -> decltype(auto) {
39 return util::get<index>(util::move(*this).self());
40 }
41
42 template<typename T>
43 requires(requires(Self& self) { util::get<T>(self); })
44 constexpr auto get() & -> decltype(auto) {
45 return util::get<T>(self());
46 }
47
48 template<typename T>
49 requires(requires(Self const& self) { util::get<T>(self); })
50 constexpr auto get() const& -> decltype(auto) {
51 return util::get<T>(self());
52 }
53
54 template<typename T>
55 requires(requires(Self&& self) { util::get<T>(util::move(self)); })
56 constexpr auto get() && -> decltype(auto) {
57 return util::get<T>(util::move(*this).self());
58 }
59
60 template<typename T>
61 requires(requires(Self const&& self) { util::get<T>(util::move(self)); })
62 constexpr auto get() const&& -> decltype(auto) {
63 return util::get<T>(util::move(*this).self());
64 }
65
66private:
68 -> bool {
69 return true;
70 }
71};
72}
di::meta::Decay< decltype(T)> Tag
Definition tag_invoke.h:28
Definition vocab.h:96
constexpr auto get(T &&value) -> decltype(auto)
Definition get.h:8
Definition in_place_type.h:5
Definition add_member_get.h:10
constexpr auto get() const &&-> decltype(auto)
Definition add_member_get.h:38
constexpr auto get() &-> decltype(auto)
Definition add_member_get.h:44
constexpr auto get() const &&-> decltype(auto)
Definition add_member_get.h:62
constexpr auto get() const &-> decltype(auto)
Definition add_member_get.h:26
constexpr auto get() &-> decltype(auto)
Definition add_member_get.h:20
constexpr auto get() &&-> decltype(auto)
Definition add_member_get.h:56
constexpr auto get() const &-> decltype(auto)
Definition add_member_get.h:50
constexpr auto get() &&-> decltype(auto)
Definition add_member_get.h:32
constexpr friend auto tag_invoke(types::Tag< vocab::enable_generate_structed_bindings >, types::InPlaceType< Self >) -> bool
Definition add_member_get.h:67