Skip to content

Commit 7a96a3f

Browse files
committed
Thread/Accessor: Deducing this
1 parent fec325e commit 7a96a3f

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

modules/Thread/UniqueLocker.mpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ export namespace CppUtils::Thread
1313
m_value{std::ref(value)}
1414
{}
1515

16-
[[nodiscard]] inline auto value() & noexcept -> T&
16+
template<class Self>
17+
[[nodiscard]] inline auto value(this Self& self) noexcept -> decltype(auto)
1718
{
18-
return m_value.get();
19+
return self.m_value.get();
1920
}
2021

21-
[[nodiscard]] inline auto operator->() & noexcept -> T*
22+
template<class Self>
23+
[[nodiscard]] inline auto operator->(this Self& self) noexcept -> decltype(auto)
2224
{
23-
return std::addressof(value());
25+
return std::addressof(self.value());
2426
}
2527

2628
[[nodiscard]] inline auto getLockGuard() & noexcept -> auto&
@@ -42,14 +44,16 @@ export namespace CppUtils::Thread
4244
m_value{std::cref(value)}
4345
{}
4446

45-
[[nodiscard]] inline auto value() & noexcept -> const T&
47+
template<class Self>
48+
[[nodiscard]] inline auto value(this Self& self) noexcept -> decltype(auto)
4649
{
47-
return m_value.get();
50+
return self.m_value.get();
4851
}
4952

50-
[[nodiscard]] inline auto operator->() & noexcept -> const T*
53+
template<class Self>
54+
[[nodiscard]] inline auto operator->(this Self& self) noexcept -> decltype(auto)
5155
{
52-
return std::addressof(value());
56+
return std::addressof(self.value());
5357
}
5458

5559
[[nodiscard]] inline auto getLockGuard() & noexcept -> auto&

0 commit comments

Comments
 (0)