This post contains some useful functions in the standard library which simplify your codes regarding string processing.
std::rotate*
template< class ForwardIt >
void rotate( ForwardIt first, ForwardIt n_first, ForwardIt last );
Performs a left rotation on a range of elements. Specifically, std::rotate swaps the elements in the range [first, last) in such a way that the element n_first becomes the first element of the new range and n_first – 1 becomes the last element.
std::substr
string substr (size_t pos = 0, size_t len = npos) const;
Note that:
If pos is equal to the string length, the function returns an empty string.
If pos is greater than the string length, it throws out_of_range.
std::find
size_t find (const string& str, size_t pos = 0) const noexcept;
std::string_view
string text_ = "Hello World";
string_view text(text_);
cout << text.substr(0, 5) << endl; // substr is O(1)
unordered_set<string_view> s;