summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/fud_string.hpp12
-rw-r--r--include/fud_vector.hpp28
2 files changed, 6 insertions, 34 deletions
diff --git a/include/fud_string.hpp b/include/fud_string.hpp
index 1d724f0..1c189c2 100644
--- a/include/fud_string.hpp
+++ b/include/fud_string.hpp
@@ -157,8 +157,7 @@ class String {
fudAssert(totalLength < maxStringLength);
String output{};
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
- output.m_allocator = reinterpret_cast<uintptr_t>(allocator);
+ output.m_allocator = std::bit_cast<uintptr_t>(allocator);
utf8* data{nullptr};
size_t outputCapacity = totalLength + 1;
bool isLarge = outputCapacity > SsoBufSize;
@@ -355,14 +354,12 @@ class String {
[[nodiscard]] static bool allocatorValid(Allocator* allocator)
{
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
- return (reinterpret_cast<uintptr_t>(allocator) & isLargeMask) == 0;
+ return (std::bit_cast<uintptr_t>(allocator) & isLargeMask) == 0;
}
[[nodiscard]] Allocator* allocator() const
{
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast,performance-no-int-to-ptr)
- auto* allocPtr = reinterpret_cast<Allocator*>(m_allocator & allocatorMask);
+ auto* allocPtr = std::bit_cast<Allocator*>(m_allocator & allocatorMask);
fudAssert(allocPtr != nullptr);
return allocPtr;
}
@@ -388,8 +385,7 @@ class String {
/** \brief The allocator used to get storage for characters when the string
* is large. */
- // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
- uintptr_t m_allocator{reinterpret_cast<uintptr_t>(&globalFudAllocator)};
+ uintptr_t m_allocator{std::bit_cast<uintptr_t>(&globalFudAllocator)};
using BufType = Array<utf8, SsoBufSize>;
union {
diff --git a/include/fud_vector.hpp b/include/fud_vector.hpp
index fd01cd0..9808a7d 100644
--- a/include/fud_vector.hpp
+++ b/include/fud_vector.hpp
@@ -95,9 +95,9 @@ class Vector {
Vector<T> output{};
auto status = initializeWithCapacity(output, capacity, allocator);
if (status != FudStatus::Success) {
- return status;
+ return Error{status};
}
- return output;
+ return Okay{std::move(output)};
}
static FudStatus initializeWithCapacity(
@@ -255,30 +255,6 @@ class Vector {
}
}
- template <typename... Args>
- static Result<Vector<T>, FudStatus> from(Option<Allocator*> allocatorOpt, Args&&... args)
- {
- constexpr size_t size = sizeof...(args);
- Vector<T> output{};
- Allocator* allocator = allocatorOpt.hasValue() ? allocatorOpt.value() : &globalFudAllocator;
- auto status = Vector::initializeWithCapacity(output, size, allocator);
- if (status != FudStatus::Success) {
- return Error{status};
- }
- output.m_length = size;
- size_t index = 0;
- /*
- for (size_t index = 0; index < output.m_length; ++index) {
-
- }
- */
- ([&]() {
- output.m_data[index] = std::forward<T>(args);
- ++index;
- } (), ...);
- return Okay{std::move(output)};
- }
-
static Vector<T> move(Vector<T>&& rhs) noexcept
{
return Vector<T>{std::move(rhs)};