diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-02-17 00:21:48 +0100 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-02-17 22:29:50 +0100 |
commit | a141c401f78467bc15f62882fca5d55a007cacbb (patch) | |
tree | 908ac71a8640f78f45d22c6808c5fa6e373000fa /asl/string.hpp | |
parent | cb77cbe9ce4cddad6a460aa190ff70f0c13e4703 (diff) |
Reorganize everything
Diffstat (limited to 'asl/string.hpp')
-rw-r--r-- | asl/string.hpp | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/asl/string.hpp b/asl/string.hpp deleted file mode 100644 index ae732f0..0000000 --- a/asl/string.hpp +++ /dev/null @@ -1,77 +0,0 @@ -#pragma once - -#include "asl/buffer.hpp" -#include "asl/string_view.hpp" - -namespace asl -{ - -template<allocator Allocator = DefaultAllocator> -class string -{ - buffer<char, Allocator> m_buffer; - - explicit constexpr string(buffer<char, Allocator>&& buffer) : - m_buffer{ASL_MOVE(buffer)} - {} - - template<allocator A> - friend class StringBuilder; - -public: - constexpr string() requires default_constructible<Allocator> = default; - explicit constexpr string(Allocator allocator) : m_buffer{ASL_MOVE(allocator)} {} - - // NOLINTNEXTLINE(*-explicit-conversions) - constexpr string(string_view sv) - requires default_constructible<Allocator> - : m_buffer{sv.as_span()} - {} - - constexpr string(string_view sv, Allocator allocator) - : m_buffer{sv.as_span(), ASL_MOVE(allocator)} - {} - - constexpr ~string() = default; - - constexpr string(const string&) requires copy_constructible<Allocator> = default; - constexpr string(string&&) = default; - - constexpr string& operator=(const string&) requires copy_assignable<Allocator> = default; - constexpr string& operator=(string&&) = default; - - constexpr isize_t size() const { return m_buffer.size(); } - constexpr const char* data() const { return m_buffer.data(); } - - // NOLINTNEXTLINE(*-explicit-conversions) - constexpr operator string_view() const - { - return as_string_view(); - } - - constexpr string_view as_string_view() const - { - auto span = m_buffer.as_span(); - return string_view{span.data(), span.size()}; - } - - constexpr bool operator==(const string& other) const - { - return as_string_view() == other.as_string_view(); - } - - constexpr bool operator==(string_view other) const - { - return as_string_view() == other; - } - - template<typename H> - friend H AslHashValue(H h, const string& str) - { - return H::combine(h, str.as_string_view()); - } -}; - -string() -> string<>; - -} // namespace asl |