summaryrefslogtreecommitdiff
path: root/asl/types
diff options
context:
space:
mode:
Diffstat (limited to 'asl/types')
-rw-r--r--asl/types/maybe_uninit.hpp20
-rw-r--r--asl/types/option.hpp20
-rw-r--r--asl/types/status_or.hpp3
3 files changed, 18 insertions, 25 deletions
diff --git a/asl/types/maybe_uninit.hpp b/asl/types/maybe_uninit.hpp
index 36429e4..e8ccbd3 100644
--- a/asl/types/maybe_uninit.hpp
+++ b/asl/types/maybe_uninit.hpp
@@ -17,9 +17,8 @@ public:
constexpr maybe_uninit() requires trivially_default_constructible<T> = default;
constexpr maybe_uninit() requires (!trivially_default_constructible<T>) {} // NOLINT
- template<typename... Args>
- explicit constexpr maybe_uninit(in_place_t, Args&&... args)
- requires constructible_from<T, Args&&...>
+ explicit constexpr maybe_uninit(in_place_t, auto&&... args)
+ requires constructible_from<T, decltype(args)...>
: m_value{ASL_FWD(args)...}
{}
@@ -39,17 +38,15 @@ public:
constexpr ~maybe_uninit() requires (!trivially_destructible<T>) {} // NOLINT
// @Safety Value must not have been initialized yet
- template<typename... Args>
- constexpr void construct_unsafe(Args&&... args)
- requires constructible_from<T, Args&&...>
+ constexpr void construct_unsafe(auto&&... args)
+ requires constructible_from<T, decltype(args)...>
{
construct_at<T>(&m_value, ASL_FWD(args)...);
}
// @Safety Value must have been initialized
- template<typename U>
- constexpr void assign_unsafe(U&& value)
- requires assignable_from<T&, U&&>
+ constexpr void assign_unsafe(auto&& value)
+ requires assignable_from<T&, decltype(value)>
{
m_value = ASL_FWD(value);
}
@@ -64,10 +61,9 @@ public:
}
// @Safety Value must have been initialized
- template<typename Self>
- constexpr auto&& as_init_unsafe(this Self&& self)
+ constexpr auto&& as_init_unsafe(this auto&& self)
{
- return ASL_FWD_LIKE(decltype(self), ASL_FWD(self).m_value);
+ return ASL_FWD(self).m_value;
}
};
diff --git a/asl/types/option.hpp b/asl/types/option.hpp
index b32483b..8b5f313 100644
--- a/asl/types/option.hpp
+++ b/asl/types/option.hpp
@@ -365,8 +365,7 @@ public:
}
}
- template<typename Self>
- constexpr auto&& value(this Self&& self)
+ constexpr auto&& value(this auto&& self)
{
ASL_ASSERT_RELEASE(self.has_value());
return ASL_FWD(self).m_payload.as_init_unsafe();
@@ -386,19 +385,18 @@ public:
return has_value() ? ASL_MOVE(value()) : static_cast<T>(ASL_FWD(other_value));
}
- template<typename... Args>
- constexpr T& emplace(Args&&... args) &
- requires constructible_from<T, Args&&...>
+ constexpr T& emplace(auto&&... args) &
+ requires constructible_from<T, decltype(args)...>
{
if (has_value()) { reset(); }
construct(ASL_FWD(args)...);
return value();
}
- template<typename F, typename Self>
- constexpr auto and_then(this Self&& self, F&& f)
+ template<typename F>
+ constexpr auto and_then(this auto&& self, F&& f)
{
- using Result = invoke_result_t<F, copy_cref_t<Self&&, T>>;
+ using Result = invoke_result_t<F, copy_cref_t<decltype(self), T>>;
static_assert(is_option<Result>);
if (self.has_value())
@@ -408,10 +406,10 @@ public:
return Result{ asl::nullopt };
}
- template<typename F, typename Self>
- constexpr auto transform(this Self&& self, F&& f)
+ template<typename F>
+ constexpr auto transform(this auto&& self, F&& f)
{
- using Result = invoke_result_t<F, copy_cref_t<Self&&, T>>;
+ using Result = invoke_result_t<F, copy_cref_t<decltype(self), T>>;
if (self.has_value())
{
return option<un_cvref_t<Result>>{
diff --git a/asl/types/status_or.hpp b/asl/types/status_or.hpp
index 5771d58..a8a48c1 100644
--- a/asl/types/status_or.hpp
+++ b/asl/types/status_or.hpp
@@ -129,8 +129,7 @@ public:
constexpr status&& throw_status() && { return ASL_MOVE(m_status); }
- template<typename Self>
- constexpr auto&& value(this Self&& self)
+ constexpr auto&& value(this auto&& self)
{
ASL_ASSERT_RELEASE(self.ok());
return ASL_FWD(self).m_value.as_init_unsafe();