summaryrefslogtreecommitdiff
path: root/asl/types
diff options
context:
space:
mode:
Diffstat (limited to 'asl/types')
-rw-r--r--asl/types/span.hpp30
-rw-r--r--asl/types/status.hpp16
-rw-r--r--asl/types/status_or.hpp10
3 files changed, 28 insertions, 28 deletions
diff --git a/asl/types/span.hpp b/asl/types/span.hpp
index 8585f17..105379b 100644
--- a/asl/types/span.hpp
+++ b/asl/types/span.hpp
@@ -77,14 +77,14 @@ public:
template<isize_t N>
constexpr span(T (&array)[N]) // NOLINT(*explicit*)
requires (kIsDynamic)
- : m_data{array}
+ : m_data{static_cast<T*>(array)}
, m_size{N}
{}
template<isize_t N>
constexpr span(T (&array)[N]) // NOLINT(*explicit*)
requires (!kIsDynamic) && (N == kSize)
- : m_data{array}
+ : m_data{static_cast<T*>(array)}
{}
template<is_object U, isize_t kOtherSize>
@@ -109,24 +109,24 @@ public:
~span() = default;
- constexpr isize_t size() const
+ [[nodiscard]] constexpr isize_t size() const
{
if constexpr (kIsDynamic) { return m_size; }
else { return kSize; }
}
- constexpr isize_t size_bytes() const { return size() * size_of<T>; }
+ [[nodiscard]] constexpr isize_t size_bytes() const { return size() * size_of<T>; }
- constexpr bool is_empty() const { return size() == 0; }
+ [[nodiscard]] constexpr bool is_empty() const { return size() == 0; }
- constexpr T* data() const { return m_data; }
+ [[nodiscard]] constexpr T* data() const { return m_data; }
- constexpr contiguous_iterator<T> begin() const
+ [[nodiscard]] constexpr contiguous_iterator<T> begin() const
{
return contiguous_iterator{m_data};
}
- constexpr contiguous_iterator<T> end() const
+ [[nodiscard]] constexpr contiguous_iterator<T> end() const
{
return contiguous_iterator{m_data + size()};
}
@@ -138,7 +138,7 @@ public:
}
template<isize_t kOffset, isize_t kSubSize = dynamic_size>
- constexpr auto subspan() const
+ [[nodiscard]] constexpr auto subspan() const
requires (
kOffset >= 0 &&
(kIsDynamic || kOffset <= kSize) &&
@@ -165,13 +165,13 @@ public:
}
}
- constexpr span<T> subspan(isize_t offset) const
+ [[nodiscard]] constexpr span<T> subspan(isize_t offset) const
{
ASL_ASSERT(offset <= size());
return span<T>{ data() + offset, size() - offset };
}
- constexpr span<T> subspan(isize_t offset, isize_t sub_size) const
+ [[nodiscard]] constexpr span<T> subspan(isize_t offset, isize_t sub_size) const
{
ASL_ASSERT(offset <= size() && !is_dynamic(sub_size));
ASL_ASSERT(sub_size <= size() - offset);
@@ -179,7 +179,7 @@ public:
}
template<isize_t kSubSize>
- constexpr auto first() const
+ [[nodiscard]] constexpr auto first() const
requires (
kSubSize >= 0 &&
(kIsDynamic || kSubSize <= kSize)
@@ -189,14 +189,14 @@ public:
return span<T, kSubSize>{ data(), kSubSize };
}
- constexpr span<T> first(isize_t sub_size) const
+ [[nodiscard]] constexpr span<T> first(isize_t sub_size) const
{
ASL_ASSERT(sub_size >= 0 && sub_size <= size());
return span<T>{ data(), sub_size };
}
template<isize_t kSubSize>
- constexpr auto last() const
+ [[nodiscard]] constexpr auto last() const
requires (
kSubSize >= 0 &&
(kIsDynamic || kSubSize <= kSize)
@@ -206,7 +206,7 @@ public:
return span<T, kSubSize>{ data() + size() - kSubSize, kSubSize };
}
- constexpr span<T> last(isize_t sub_size) const
+ [[nodiscard]] constexpr span<T> last(isize_t sub_size) const
{
ASL_ASSERT(sub_size >= 0 && sub_size <= size());
return span<T>{ data() + size() - sub_size, sub_size };
diff --git a/asl/types/status.hpp b/asl/types/status.hpp
index 83be5ce..df96cd8 100644
--- a/asl/types/status.hpp
+++ b/asl/types/status.hpp
@@ -38,12 +38,12 @@ class status
return static_cast<status_code>(bit_cast<uintptr_t>(payload) >> 1);
}
- constexpr bool is_inline() const
+ [[nodiscard]] constexpr bool is_inline() const
{
return m_payload == nullptr || (bit_cast<uintptr_t>(m_payload) & 1) != 0;
}
- constexpr status_code code_inline() const
+ [[nodiscard]] constexpr status_code code_inline() const
{
ASL_ASSERT(is_inline());
if (m_payload == nullptr)
@@ -53,8 +53,8 @@ class status
return payload_to_status(m_payload);
}
- status_code code_internal() const;
- string_view message_internal() const;
+ [[nodiscard]] status_code code_internal() const;
+ [[nodiscard]] string_view message_internal() const;
void ref();
void unref();
@@ -103,17 +103,17 @@ public:
return *this;
}
- constexpr bool ok() const
+ [[nodiscard]] constexpr bool ok() const
{
return m_payload == nullptr;
}
- constexpr status_code code() const
+ [[nodiscard]] constexpr status_code code() const
{
return is_inline() ? code_inline() : code_internal();
}
- constexpr string_view message() const
+ [[nodiscard]] constexpr string_view message() const
{
if (!is_inline())
{
@@ -156,6 +156,6 @@ ASL_DEFINE_ERROR_(internal)
ASL_DEFINE_ERROR_(runtime)
ASL_DEFINE_ERROR_(invalid_argument)
-#define ASL_TRY(VALUE) if (VALUE.ok()) {} else { return std::move(VALUE).throw_status(); }
+#define ASL_TRY(VALUE) if ((VALUE).ok()) {} else { return std::move(VALUE).throw_status(); }
} // namespace asl
diff --git a/asl/types/status_or.hpp b/asl/types/status_or.hpp
index 7794596..f60a48e 100644
--- a/asl/types/status_or.hpp
+++ b/asl/types/status_or.hpp
@@ -99,13 +99,13 @@ public:
}
}
- // NOLINTNEXTLINE(*-explicit-conversions)
+ // NOLINTNEXTLINE(*explicit*)
constexpr status_or(const status& status) : m_status{status}
{
ASL_ASSERT_RELEASE(!m_status.ok());
}
- // NOLINTNEXTLINE(*-explicit-conversions)
+ // NOLINTNEXTLINE(*explicit*)
constexpr status_or(status&& status) : m_status{std::move(status)}
{
ASL_ASSERT_RELEASE(!m_status.ok());
@@ -125,11 +125,11 @@ public:
, m_value{in_place, std::forward<U>(value)}
{}
- constexpr bool ok() const { return m_status.ok(); }
+ [[nodiscard]] constexpr bool ok() const { return m_status.ok(); }
- constexpr status_code code() const { return m_status.code(); }
+ [[nodiscard]] constexpr status_code code() const { return m_status.code(); }
- constexpr string_view message() const { return m_status.message(); }
+ [[nodiscard]] constexpr string_view message() const { return m_status.message(); }
constexpr status&& throw_status() && { return std::move(m_status); }