11#pragma once
22
3- #include " utility/cast_to .h"
3+ #include " stdsharp/concepts/concepts .h"
44#include " type_traits/core_traits.h"
55
66namespace stdsharp
77{
88 template <typename T>
9- class default_increase_and_decrease
9+ class default_increase
1010 {
1111 [[nodiscard]] friend constexpr auto operator ++(T& t, int ) //
1212 noexcept (nothrow_copy_constructible<T>&& noexcept (++t))
@@ -28,7 +28,7 @@ namespace stdsharp
2828 };
2929
3030 template <typename T>
31- class default_arithmetic_operator : default_increase_and_decrease <T>
31+ class default_arithmetic_operator : default_increase <T>
3232 {
3333 friend constexpr T& operator ++(T& t) noexcept (noexcept (t += 1 ))
3434 requires requires { t += 1 ; }
@@ -76,16 +76,49 @@ namespace stdsharp
7676 template <typename T>
7777 class default_arrow_operator
7878 {
79- [[nodiscard]] constexpr decltype (auto ) operator->() const noexcept (noexcept (*static_cast <const T&>(*this )))
80- requires dereferenceable<const T&>
79+ [[nodiscard]] constexpr decltype (auto ) operator->() const
80+ noexcept (noexcept (*static_cast <const T&>(*this )))
81+ requires dereferenceable<const T>
8182 {
8283 return *static_cast <const T&>(*this );
8384 }
8485
85- [[nodiscard]] constexpr decltype (auto ) operator->() noexcept (noexcept (*static_cast <T&>(*this )))
86- requires dereferenceable<T&>
86+ [[nodiscard]] constexpr decltype (auto ) operator->() //
87+ noexcept (noexcept (*static_cast <T&>(*this )))
88+ requires dereferenceable<T>
8789 {
8890 return *static_cast <T&>(*this );
8991 }
92+
93+ [[nodiscard]] friend constexpr decltype (auto ) operator->*(const T & t, auto && ptr) //
94+ noexcept (noexcept ((*t).*cpp_forward(ptr)))
95+ requires dereferenceable<const T>
96+ {
97+ return (*t).*cpp_forward (ptr);
98+ }
99+
100+ [[nodiscard]] friend constexpr decltype (auto ) operator->*(T & t, auto && ptr) //
101+ noexcept (noexcept ((*t).*cpp_forward(ptr)))
102+ requires dereferenceable<T>
103+ {
104+ return (*t).*cpp_forward (ptr);
105+ }
106+ };
107+
108+ template <typename T>
109+ class default_subscriptor
110+ {
111+ #if __cpp_multidimensional_subscript >= 202110L
112+ [[nodiscard]] constexpr decltype (auto ) operator[](auto && first_arg, auto &&... args) //
113+ noexcept ( //
114+ noexcept (static_cast <const T&>(*this )[cpp_forward(first_arg)][cpp_forward(args)...])
115+ )
116+ requires requires {
117+ static_cast <const T&>(*this )[cpp_forward (first_arg)][cpp_forward (args)...];
118+ }
119+ {
120+ return static_cast <const T&>(*this )[cpp_forward (first_arg)][cpp_forward (args)...];
121+ }
122+ #endif
90123 };
91124}
0 commit comments