Getting ready

The string library we will be implementing should work with all the standard string types, std::string, std::wstring, std::u16string, and std::u32string. To avoid specifying long names such as std::basic_string<CharT, std::char_traits<CharT>, std::allocator<CharT>>, we will use the following alias templates for strings and string streams:

    template <typename CharT> 
using tstring =
std::basic_string<CharT, std::char_traits<CharT>,
std::allocator<CharT>>;

template <typename CharT>
using tstringstream =
std::basic_stringstream<CharT, std::char_traits<CharT>,
std::allocator<CharT>>;

To implement these string helper functions, we need to include the header <string> for strings and <algorithm> for the general standard algorithms we will use.

In all the examples in this recipe, we will use the standard user-defined literal operators for strings from C++14, for which we need to explicitly use the std::string_literals namespace.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset