idioms strings - RawIron/learn-cpp GitHub Wiki
String Streams
std::stringstream ss{};
ss << name << " is " << age << " years old.";
string sentence = ss.str();
C++20
std::format("{0} is {1} years old.", age, name);
format strings in Python
f"{name} is {age} years old."
https://stackoverflow.com/questions/37956090/string-interpolation-in-c-construct-a-stdstring-with-embedded-values-e-g https://github.com/fmtlib/fmt
- align, width, precision
- multi-line
SELECT name
FROM players
- raw strings, for example regular expressions
// syntax is R"(..)"
R"([a-z]+(\.[a-z]+)?@gmail\.com$)"
https://solarianprogrammer.com/2011/10/16/cpp-11-raw-strings-literals-tutorial/
#include <regex>
std::regex gmail_pattern(R"([a-z]+(\.[a-z]+)?@gmail\.com$)");
if (std::regex_match(emailAddr, gmail_pattern)) { .. }
- iterate over all matches
- split
- join
- conversion fromString, toString
https://stackoverflow.com/questions/5590381/easiest-way-to-convert-int-to-string-in-c