Skip to content

Commit 5e9b92a

Browse files
committed
feat(arrow-operator): implemented
1 parent 39dfa14 commit 5e9b92a

File tree

14 files changed

+98
-46
lines changed

14 files changed

+98
-46
lines changed

include/stdsharp/compare/compare.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace stdsharp
2121
}
2222

2323
template<typename Fn, typename T, typename U, typename Cat = std::partial_ordering>
24-
concept ordering_predicate = ordering_like<Cat> && invocable_r<Fn, Cat, T, U>;
24+
concept ordering_predicate = ordering_like<Cat> && regular_invocable_r<Fn, Cat, T, U>;
2525

2626
template<typename Fn, typename T, typename U, typename Cat = std::partial_ordering>
2727
concept nothrow_ordering_predicate =

include/stdsharp/concepts/concepts.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,12 @@ namespace stdsharp
422422
concept nothrow_invocable_r = std::is_nothrow_invocable_r_v<ReturnT, Func, Args...>;
423423

424424
template<typename Func, typename ReturnT, typename... Args>
425-
concept regular_invocable_r = std::regular_invocable<Func, ReturnT, Args...> &&
426-
std::is_invocable_r_v<ReturnT, Func, Args...>;
425+
concept regular_invocable_r =
426+
std::regular_invocable<Func, Args...> && invocable_r<Func, ReturnT, Args...>;
427427

428428
template<typename Func, typename ReturnT, typename... Args>
429-
concept nothrow_regular_invocable_r = std::regular_invocable<Func, ReturnT, Args...> &&
430-
nothrow_invocable_r<ReturnT, Func, Args...>;
429+
concept nothrow_regular_invocable_r = regular_invocable_r<Func, ReturnT, Args...> &&
430+
nothrow_invocable_r<Func,ReturnT, Args...>;
431431

432432
template<typename Func, typename... Args>
433433
concept nothrow_predicate = nothrow_invocable_r<Func, bool, Args...>;

include/stdsharp/default_operator.h

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#pragma once
22

3-
#include "utility/cast_to.h"
3+
#include "stdsharp/concepts/concepts.h"
44
#include "type_traits/core_traits.h"
55

66
namespace 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
}

include/stdsharp/enumeration.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include "utility/auto_cast.h"
4-
#include "concepts/concepts.h"
54

65
namespace stdsharp
76
{

include/stdsharp/memory/aligned.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#pragma once
22

3+
#include <span>
4+
35
#include "pointer_traits.h"
6+
#include "../cstdint/cstdint.h"
47

58
namespace stdsharp
69
{

include/stdsharp/memory/allocation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "allocator_traits.h"
44
#include "../functional/compose.h"
5+
#include "../ranges/ranges.h"
56

67
namespace stdsharp::details
78
{

include/stdsharp/memory/allocation_value.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include "../algorithm/algorithm.h"
34
#include "allocation_traits.h"
45
#include "launder_iterator.h"
56

include/stdsharp/memory/allocator_traits.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "../type_traits/special_member.h"
88
#include "../utility/constructor.h"
9+
#include "../cassert/cassert.h"
910
#include "pointer_traits.h"
1011

1112
namespace stdsharp::details

include/stdsharp/memory/pointer_traits.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#include <memory>
44

55
#include "../type_traits/object.h"
6+
#include "../functional/invocables.h"
7+
#include "../utility/auto_cast.h"
8+
69
#include "../compilation_config_in.h"
710

811
namespace stdsharp

include/stdsharp/ranges/ranges.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//
2-
3-
//
41
#pragma once
52

63
#include <ranges>

0 commit comments

Comments
 (0)