Skip to main content

~upd~ - C++ 2017

void print(std::string_view sv) std::cout << sv;

template<auto N> struct Foo ; Foo<42> f1; Foo<'c'> f2; 3.1 std::optional<T> A type-safe wrapper that may or may not hold a value. c++ 2017

g++ -std=c++17 program.cpp clang++ -std=c++17 program.cpp cl /std:c++17 program.cpp # MSVC C++17 is often described as a "quality-of-life" release because it addressed many everyday pain points without introducing radical new paradigms (unlike C++11 or C++20). It made C++ more approachable and efficient, and most codebases quickly adopted its features. parse_int(const std::string& s) try return std::stoi(s)

std::optional<int> parse_int(const std::string& s) try return std::stoi(s); catch(...) return std::nullopt; catch(...) return std::nullopt

std::any a = 42; int value = std::any_cast<int>(a); Non-owning reference to a string-like sequence. Ideal for function parameters.

template <typename T> auto to_string(const T& t) if constexpr (std::is_integral_v<T>) return std::to_string(t); else return std::string(t); // only instantiated if T is not integral