Sections[lib]
Standard Library
The library that ships with every compiler, from containers and algorithms to ranges and smart pointers, for developers choosing which type to reach for first.
- Clause
- 2 of 8
- Answers
- 34, newest first
- Page
- 4 of 4
- Written for
- C++17, C++20, C++23
- Written by
- Miriam Castellanos
Answers in Standard Library 34, newest first
std::optionalin C++: how to use it and when not toCreate, test, read, empty and refill a
std::optional, what each accessor does when it is empty, what it costs, and whenstd::expectedfits better.written for C++17
std::printlnin C++23: print withoutstd::coutor printfstd::printlnin C++23: the syntax, eachstd::coutand printf line translated, what a bad format string does, whether it flushes, andstd::endlvs newline.written for C++23
std::spanin C++20: pass a view, not a pointer and a sizeTake
std::spanby value: what converts to it, slicing with subspan, what s[i] out of range does on each library, and how a span dangles.written for C++20
std::variantin C++:std::visit,std::getand the trapsCreate a
std::variant, read it withstd::get,get_iforstd::visit, catch the missing case a conversion hides, and see what it costs and when to skip it.written for C++17