Something went wrong. Try again.
A Tour of C++ for experienced programmers, as if C++26 is the only version that ever existed.
Something went wrong. Try again.
12345678910111213141516171819#include <iostream>#include <utility>#include <string_view>
// Simple parser that returns {true,42} for the literal "42",// otherwise returns {false,0}.std::pair<bool,int> try_parse(std::string_view s) { if (s == "42") return {true, 42}; return {false, 0};}
int main() { std::string_view input = "42"; if (auto [ok, n] = try_parse(input); ok) { std::cout << "got " << n << '\n'; } return 0;}