Utilities for C++s
C++ utilities cover everyday standard library tools for text and failure handling. Strings include std::string and std::string_view, with formatting through std::format or streams, and error handling spans exceptions, error codes and types like std::optional and std::expected. Choosing a consistent error strategy keeps code predictable and easy to maintain.
Stage: Standard Library · Part of the C++ roadmap · Last reviewed 19 November 2026
What to learn in Utilities
- Build and format text with std::string and std::format
- Use string_view to avoid copying read-only text
- Throw and catch exceptions and keep functions exception safe
- Return optional values instead of sentinel numbers
- Decide between exceptions and error codes for a given API
Utilities interview questions
What is std::string_view and what is its main risk?
It is a non-owning view of a contiguous character sequence, so passing it avoids copies. The risk is lifetime: if the underlying string is destroyed or changed, the view dangles. Never return a view of a local string.
What does exception safety mean?
It describes what state a function leaves behind when an exception is thrown. The basic guarantee means no leaks and valid objects. The strong guarantee means the operation either completes or has no effect. RAII is the main tool for achieving both.
Where Utilities fits in the C++ roadmap
Utilities belongs to the Standard Library stage (advanced level), which takes about 37 hours. Containers and algorithms.