diff options
Diffstat (limited to 'source/fud_string.cpp')
-rw-r--r-- | source/fud_string.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/fud_string.cpp b/source/fud_string.cpp index 37a2a4b..a2a62f4 100644 --- a/source/fud_string.cpp +++ b/source/fud_string.cpp @@ -21,6 +21,19 @@ namespace fud { +StringResult String::withAllocator(Allocator& allocator) +{ + if (!String::allocatorValid(&allocator)) + { + return Error{FudStatus::ArgumentInvalid}; + } + + String output{}; + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) + output.m_allocator = reinterpret_cast<uintptr_t>(&allocator); + return Okay{std::move(output)}; +} + StringResult String::makeFromCString(const char8_t* cString) { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) |