diff options
| -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. |
