diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-07-02 19:20:39 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-07-02 19:20:39 +0200 |
| commit | 3b2e03acb3fdf19e5546c29363fa538f59da22df (patch) | |
| tree | 29efa83b6ef68e094a4578cb9ce6c23be2e782a8 /libs | |
| parent | a24e133b7b90afae64b3edf0d8dd29b6e98a250b (diff) | |
| download | kernel-3b2e03acb3fdf19e5546c29363fa538f59da22df.tar.xz kernel-3b2e03acb3fdf19e5546c29363fa538f59da22df.zip | |
kstd: implement some assign overloads for string
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/kstd/kstd/bits/basic_string.hpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libs/kstd/kstd/bits/basic_string.hpp b/libs/kstd/kstd/bits/basic_string.hpp index c780a083..1675434c 100644 --- a/libs/kstd/kstd/bits/basic_string.hpp +++ b/libs/kstd/kstd/bits/basic_string.hpp @@ -408,6 +408,36 @@ namespace kstd //! Assignment from nullptr is prohibited. constexpr auto operator=(std::nullptr_t) = delete; + //! Assign a new value to this string. + //! + //! @param string The string to use to replace this strings value. + //! @return A reference to this string after assignment. + constexpr auto assign(basic_string const & string) -> basic_string & + { + return *this = string; + } + + //! Assign a new value to this string. + //! + //! @param string The string to use to replace this strings value. + //! @return A reference to this string after assignment. + constexpr auto assign(basic_string && string) noexcept(noexcept(*this = std::move(string))) -> basic_string & + { + return *this = std::move(string); + } + + //! Replace the contents of this string with a given number of copies of a given character. + //! + //! @param count The number of copies. + //! @param character The character to use to fill this string. + //! @return A reference to this string after assignment. + constexpr auto assign(size_type count, CharacterType character) -> basic_string & + { + clear(); + resize(count, character); + return *this; + } + //! Get the allocator used by this string. //! //! @return A copy of the allocator used by this string. |
