Skip to content

Commit 39dfa14

Browse files
committed
feat(arrow-operator)
1 parent 8272b9e commit 39dfa14

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

include/stdsharp/default_operator.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace stdsharp
2828
};
2929

3030
template<typename T>
31-
class default_arithmetic_operation : default_increase_and_decrease<T>
31+
class default_arithmetic_operator : default_increase_and_decrease<T>
3232
{
3333
friend constexpr T& operator++(T& t) noexcept(noexcept(t += 1))
3434
requires requires { t += 1; }
@@ -72,4 +72,20 @@ namespace stdsharp
7272
return 0 - t;
7373
};
7474
};
75+
76+
template<typename T>
77+
class default_arrow_operator
78+
{
79+
[[nodiscard]] constexpr decltype(auto) operator->() const noexcept(noexcept(*static_cast<const T&>(*this)))
80+
requires dereferenceable<const T&>
81+
{
82+
return *static_cast<const T&>(*this);
83+
}
84+
85+
[[nodiscard]] constexpr decltype(auto) operator->() noexcept(noexcept(*static_cast<T&>(*this)))
86+
requires dereferenceable<T&>
87+
{
88+
return *static_cast<T&>(*this);
89+
}
90+
};
7591
}

include/stdsharp/filesystem/filesystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace stdsharp::filesystem
1414

1515
template<typename Rep, std::uintmax_t Num, std::uintmax_t Denom>
1616
class space_size<Rep, std::ratio<Num, Denom>> :
17-
default_arithmetic_operation<space_size<Rep, std::ratio<Num, Denom>>>
17+
default_arithmetic_operator<space_size<Rep, std::ratio<Num, Denom>>>
1818
{
1919
public:
2020
using rep = Rep;

include/stdsharp/memory/launder_iterator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace stdsharp
99
{
1010
template<typename T> // NOLINTBEGIN(*-pointer-arithmetic)
1111
class launder_iterator :
12-
default_arithmetic_operation<launder_iterator<T>>,
12+
default_arithmetic_operator<launder_iterator<T>>,
1313
public std::random_access_iterator_tag
1414
{
1515
T* ptr_;

0 commit comments

Comments
 (0)