summaryrefslogtreecommitdiff
path: root/asl/status.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'asl/status.hpp')
-rw-r--r--asl/status.hpp35
1 files changed, 29 insertions, 6 deletions
diff --git a/asl/status.hpp b/asl/status.hpp
index c494759..4d54b61 100644
--- a/asl/status.hpp
+++ b/asl/status.hpp
@@ -49,7 +49,9 @@ class status
}
status_code code_internal() const;
+ string_view message_internal() const;
+ void ref();
void unref();
public:
@@ -57,10 +59,7 @@ public:
constexpr ~status()
{
- if (!is_inline())
- {
- unref();
- }
+ if (!is_inline()) { unref(); }
}
explicit constexpr status(status_code code)
@@ -69,10 +68,27 @@ public:
status(status_code code, string_view msg);
+ constexpr status(const status& other)
+ : m_payload{other.m_payload}
+ {
+ if (!is_inline()) { ref(); }
+ }
+
constexpr status(status&& other)
: m_payload{exchange(other.m_payload, nullptr)}
{}
+ constexpr status& operator=(const status& other)
+ {
+ if (&other != this)
+ {
+ if (!is_inline()) { unref(); }
+ m_payload = other.m_payload;
+ if (!is_inline()) { ref(); }
+ }
+ return *this;
+ }
+
constexpr status& operator=(status&& other)
{
if (&other != this)
@@ -82,8 +98,6 @@ public:
return *this;
}
- // @Todo Copy constructor & assignment
-
constexpr bool ok() const
{
return m_payload == nullptr || code() == status_code::ok;
@@ -96,6 +110,15 @@ public:
{
return is_inline() ? code_inline() : code_internal();
}
+
+ constexpr string_view message() const
+ {
+ if (!is_inline())
+ {
+ return message_internal();
+ }
+ return {};
+ }
};
} // namespace asl