std::string_view is a C++17 standard-library view that provides read-only access to an existing contiguous character sequence without copying it. Include <string_view> when using it. section 7.1.3
A view does not own its characters, so the original string must remain in scope while the view is used. Letting that string disappear makes the view invalid. section 7.1.3
Avoiding a substring copy
In the answer smash game, word.substr(0, offset) creates a temporary string before concatenation. std::format("{}{}", std::string_view(word).substr(0, offset), second_word) views the prefix instead, avoiding that substring copy.
