xieite ::str_replace ()
Defined in header <xieite/data/str_replace.hpp>
Replaces all occurrences of a substring within a string with yet another string.
Declaration
#0template <typename Char ,typename Traits ,typename Alloc =std ::allocator <Char >> [[nodiscard ]]constexpr std ::basic_string <Char ,Traits ,Alloc >str_replace (std ::basic_string_view <Chars ,Traits >strv ,std ::type_identity_t <std ::basic_string_view <Char ,Traits >>orig ,std ::type_identity_t <std ::basic_string_view <Char ,Traits >>with ,const Alloc & alloc = {})noexcept (false );
#1
template <typename Char ,typename Traits ,typename Alloc =std ::allocator <Char >> [[nodiscard ]]constexpr auto str_replace (std ::basic_string_view <Chars ,Traits >strv ,Char orig ,std ::type_identity_t <std ::basic_string_view <Char ,Traits >>with ,const Alloc & alloc = {})noexcept (false );
#2
template <typename Char ,typename Traits ,typename Alloc =std ::allocator <Char >> [[nodiscard ]]constexpr auto str_replace (std ::basic_string_view <Chars ,Traits >strv ,std ::type_identity_t <std ::basic_string_view <Char ,Traits >>orig ,Char with ,const Alloc & alloc = {})noexcept (false );
#3
template <typename Char ,typename Traits ,typename Alloc =std ::allocator <Char >> [[nodiscard ]]constexpr auto str_replace (std ::basic_string_view <Chars ,Traits >strv ,Char orig ,Char with ,const Alloc & alloc = {})noexcept (false );
#4
template <typename Char ,typename Traits ,typename Alloc > [[nodiscard ]]constexpr auto str_replace (const std ::basic_string <Char ,Traits ,Alloc >& str ,auto&& orig ,auto&& with ,const Alloc & alloc = {})noexcept (false );
#5
template <xieite ::is_char Char ,typename Traits =std ::char_traits <Char >,typename Alloc =std ::allocator <Char >,std ::size_t length > [[nodiscard ]]constexpr auto str_replace (const xieite ::paren <Char [length ]>& str ,auto&& orig ,auto&& with ,const Alloc & alloc = {})noexcept (false );
Example
Output:int main () {xieite ::dump (xieite ::str_replace ("Hello, %NAME%!" ,"%NAME%" ,"world" )); }
[View in Compiler Explorer]Hello, world!