- General information
- Design principles
- Algorithms
- Concepts
- Containers
- Exceptions
- Input/output
- Iterators
- Ranges
- Memory
- Numerics
- Regular expressions
- Type support
- Utilities
- Date and time utilities
- Filesystem
- Tricks and subtleties
- The Standard Template Library (STL)
🔗
- S.Love. Are you afraid of the dark? – Making sense of the STL – Overload 43 (2001)
🎥
- S.Dargo. Undefined behaviour in the STL – C++ on Sea (2020)
📖
- J.Galowicz. C++17 STL cookbook: Discover the latest enhancements to functional programming and lambda expressions (2017)
- N.M.Josuttis. The C++ standard library: A tutorial and reference (2012)
⚓
- B.Revzin. The mothership has landed: Adding
<=>
to the library – WG21/P1614
🔗
🎥
- A.Stepanov. STL and its design principles (2002)
- B.Steagall. Back to basics: Classic STL – CppCon (2021)
🔗
- S.Dargo. The big STL algorithms tutorial: wrapping up (2022)
- S.Dargo. The big STL algorithms tutorial: the memory header (2022)
- S.Dargo. The big STL algorithms tutorial: more numeric algorithms (2022)
- S.Dargo. The big STL algorithms tutorial: Introduction (2019)
🎥
- C.Hoekstra. Algorithm intuition. Part I, Part II – CppCon (2019)
- J.Boccara. 105 STL algorithms in less than an hour – ACCU (2018)
- J.Boccara. 105 STL algorithms in less than an hour – CppCon (2018)
- M.Clow. STL algorithms: How to use them and how to write your own – ACCU (2016)
- M.Clow. STL algorithms: Why you should use them, and how to write your own – CppCon (2016)
- M.VanLoon. STL algorithms in action – CppCon (2015)
🔗
- S.Parent. #iotashaming (2019)
❔
- What does iota of
std::iota
stand for? – Stack Overflow
🎥
- S.Tóth. The dark corner of STL: MinMax algorithms – CppCon (2022)
- W.E.Brown. Correctly calculating
min
,max
, and more – What can go wrong – Meeting C++ (2021)
🎥
- M.Clow.
std::midpoint
? How hard could it be? – CppCon (2019)
⚓
- S.D.Herring. Well-behaved interpolation for numbers and pointers – WG21/P0811
❔
- How to create a permutation using STL for number of places lower than the total length? – Stack Overflow
⚓
std::next_permutation
– C++ referencestd::prev_permutation
– C++ referencestd::is_permutation
– C++ reference
🔗
- A.Demin. How sorting is implemented in the standard library (in Russian, 2009)
❔
- How can I sort two vectors in the same way, with criteria that uses only one of the vectors? – Stack Overflow
🔗
- A.A.Stepanov, M.A.Marcus. Sec. 3: Partition algorithms – Notes for the Foundations of programming course (2004–2005)
❔
stable_partition
on forward iterators – Stack Overflow- How is
stable_partition
an adaptive algorithm? – Stack Overflow
🔗
- S.Dargo. The big STL algorithms tutorial: numeric scans (2022)
⚓
std::exclusive_scan
– C++ referencestd::transform_exclusive_scan
– C++ referencestd::inclusive_scan
– C++ referencestd::transform_inclusive_scan
– C++ reference
See also Concepts – Templates.
❔
Why does same_as
concept check type equality twice? – Stack Overflow
❔
- Nesting
std::
containers of movable objects – Stack Overflow - Does C++11 allow
vector<const T>
? – Stack Overflow - What’s the best way to iterate over two or more containers simultaneously – Stack Overflow
🎥
- B.Steagall. If I had my ’druthers: A proposal for improving the containers in C++2x – C++Now (2018)
- D.Higgins. Using STL containers efficiently – CppCon (2016)
- M.Clow. Customizing the standard containers – CppCon (2016)
- B.Stroustrup. Why you should avoid linked lists – Going Native (2012)
Associative containers are:
std::set
(collection of unique keys, sorted by keys),std::map
(collection of key-value pairs, sorted by keys, keys are unique),std::multiset
(collection of keys, sorted by keys), andstd::multimap
(collection of key-value pairs, sorted by keys).
🔗
- P.J.Plauger. Standard C/C++: Implementing associative containers – C/C++ Users Journal 15 (1997)
🔗
- A.O’Dwyer. Implementation divergence with a moved-from
set
comparator (2023) - K.Kreft, A.Langer. Effective standard C++ library: Are
set
iterators mutable or immutable – C/C++ Users Journal 18 (2000) - M.Austern. Why you shouldn’t use
set
– and what you should use instead – C++ Report (2000)
❔
insert
vsemplace
vsoperator[]
in C++std::map
– Stack Overflow- Is there any reason to use
std::map::emplace()
instead oftry_emplace()
in C++1z? – Stack Overflow
Sequence containers are:
std::array
(static contiguous array),std::vector
(dynamic contiguous array),std::deque
(double-ended queue),std::forward_list
(singly-linked list), andstd::list
(doubly-linked list).
See also Arrays and vectors – Sequence data structures and algorithms.
🔗
- A.O’Dwyer. The “array size constant” antipattern (2020)
❔
- Create
N
-elementconstexpr
array in C++11 – Stack Overflow - Why isn’t
std::array::size
static? – Stack Overflow
❔
- What really is a deque in STL? – Stack Overflow
- Why is an STL deque not implemented as just a circular vector? – Stack Overflow
- How can references be valid while iterators become invalidated in a deque – Stack Overflow
- STL deque accessing by index is
O(1)
? – Stack Overflow
Before this container was standardized, some Standard library implementations provided
std::slist
container as an extention.
🔗
- P.J.Plauger. Standard C/C++: A singly linked list – C/C++ Users Journal 18 (2000)
🔗
- H.Hinnant. On
std::list::size
- P.J.Plauger. Standard C/C++: A better list – C/C++ Users Journal 17 (1999)
❔
- Is
list::size()
reallyO(n)
? – Stack Overflow - Why is
std::list
bigger on C++11? – Stack Overflow - Why does
std::list::reverse
haveO(n)
complexity? – Stack Overflow - Why does
std::list
haveremove
andremove_if
functions – Stack Overflow
⚓
🔗
- A.Fertig.
push_back
vsemplace_back
: When to use what (2023) - A.O’Dwyer. What is the “vector pessimization”? (2022)
- G.Romer. TotW #112:
emplace
vs.push_back
` – Abseil C++ Tips - R.Getov. Persistent vector iterators – C/C++ Users Journal 17 (1999)
folly::fbvector
❔
- How to enforce move semantics when a vector grows? – Stack Overflow
- Making
std::vector
allocate aligned memory – Stack Overflow - What is the ideal growth rate for a dynamically allocated array? – Stack Overflow
- Why would I ever use
push_back
instead ofemplace_back
? – Stack Overflow - Can
std::vector
emplace_back
copy construct from an element of the vector itself? – Stack Overflow - Is inserting an element of a
std::vector
into the same vector allowed? – Stack Overflow - How can I propagate
const
when returning astd::vector<int*>
from aconst
method? – Stack Overflow
📖
- B.Stroustrup. Making a
vector
fit for a standard – S.B.Lippman. C++ gems: Programming pearls from The C++ report (1997) - T.Cargill. A dynamic vector is harder than it looks – S.B.Lippman. C++ gems: Programming pearls from The C++ report (1997)
🔗
- H.Hinnant. On
vector<bool>
(2012)
❔
- Why is
vector<bool>
not an STL container? – Stack Overflow
The class template
bitset
represents a fixed-size sequence ofN
bits. Bitsets can be manipulated by standard logic operators and converted to and from strings and integers.
❔
- What is the performance of
std::bitset
? – Stack Overflow - Is there any advantage to C-style bit manipulation over
std::bitset
? – Software Engineering
⚓
std::bitset
– C++ reference
The class template
std::basic_string
stores and manipulates sequences ofchar
-like objects, which are non-array objects of trivial standard-layout type.
📝
std::basic_string<T, ...>
is the only container in the standard library that requiresT
to be a trivial standard-layout type.
🔗
- R.Chen. An informal comparison of the three major implementations of
std::string
(2024) - A.Mertz.
std::string
is not a container for raw data (2018) - O.Betts. Empty strings in C++ (2013)
- H.Sutter. GotW #29: Strings – Guru of the Week (2009)
- P.Becker. Questions & Answers: The complex evolution of
<string>
– C/C++ Users Journal 16 (1998) - P.J.Plauger. Standard C/C++: The header
<string>
– C/C++ Users Journal 13 (1995)
❔
- Why
std::string
does not haveconst char*
cast – Stack Overflow - Why doesn’t
std::string
provide implicit conversion tochar*
? – Stack Overflow - Is it safe to append
std::string
to itself? – Stack Overflow - How do I check if a C++
std::string
starts with a certain string, and convert a substring to anint
? – Stack Overflow - Most optimized way of concatenation in strings – Stack Overflow
- Why are there so many string classes in the face of
std::string
? – Software Engineering
🎥
- B.Ruth.
std::basic_string
: For more than just text – CppCon (2018)
⚓
std::basic_string
– C++ reference
See also Local buffer optimization – Patterns, idioms, and design principles.
❔
- Meaning of acronym SSO in the context of
std::string
– Stack Overflow
The class template
std::basic_string_view
describes an object that can refer to a constant contiguous sequence ofchar
-like objects.
🔗
- A.O’Dwyer. Three reasons to pass
std::string_view
by value (2021) - J.Miller. C++
std::string_view
for better performance: An example use case (2019) - A.O’Dwyer.
std::string_view
is a borrow type (2018) - J.Müller.
std::string_view
accepting temporaries: good idea or horrible pitfall? (2017) - M.Chastain. TotW #1:
string_view
– Abseil C++ Tips
❔
- How exactly is
std::string_view
faster thanconst std::string&
? – Stack Overflow - Is a
std::string_view
literal guaranteed to be null-terminated? – Stack Overflow
🎥
- V.Ciura Enough
string_view
to hang ourselves – CppCon (2018) - M.Clow.
string_view
: When to use it and when not – CppCon (2015) - N.MacIntosh. Evolving
array_view
andstring_view
for safe C++ code – CppCon (2015)
❔
- Is it guaranteed to be safe to perform
memcpy(0, 0, 0)
? – Stack Overflow
Unordered containers are:
std::unordered_set
(collection of unique keys, hashed by keys),std::unordered_map
(collection of key-value pairs, hashed by keys, keys are unique),std::unordered_multiset
(collection of keys, hashed by keys), andstd::unordered_multimap
(collection of key-value pairs, hashed by keys).
🔗
- A.O’Dwyer.
unordered_multiset
’s API affects its big-O (2022) - J.M.López Muñoz. Advancing the state of the art for
std::unordered_map
implementations – Overload 170 (2022) - J.M.López Muñoz. Advancing the state of the art for
std::unordered_map
implementations (2022) - P.Trettner. Measuring
std::unordered_map
badness (2021) - N.Wu. Blowing up
unordered_map
, and how to stop getting hacked on it (2018) - P.J.Plauger. Standard C/C++: Hash tables – C/C++ Users Journal 16 (1998)
❔
- How
std::unordered_map
is implemented – Stack Overflow - How does C++ STL
unordered_map
resolve collisions? – Stack Overflow - Why is
unordered_map
“find
+insert
” faster than “insert
+ check for success”? – Stack Overflow - Performance of
emplace
is worse than check followed byemplace
– Stack Overflow
🎥
- D.Kühl. #Hashing – ACCU (2019)
- M.Skarupke. You can do better than
std::unordered_map
: New improvements to hash table performance – C++Now (2018)
⚓
- M.Austern. A proposal to add hash tables to the standard library – WG21/N1456
- J.M.López Muñoz.
erase(iterator)
for unordered containers should not return an iterator – WG21/N2023 - J.Lakos, P.Halpern. Equality comparison for unordered container – WG21/N2986
- M.Pusz. Heterogeneous lookup for unordered containers – WG21/P0919
- A.Tavory, V.Dreizin, B.Kosnik. Hash table design – Policy-based data structures
🔗
- A.O’Dwyer. Don’t reopen namespace
std
(2021)
❔
⚓
std::hash
– C++ reference- C++ named requirements: Hash – C++ reference
- W.E.Brown. Adjuncts to
std::hash
– WG21/P0549
❔
⚓
std::stack
– C++ referencestd::stack
– SGI STL
❔
- Why doesn’t
std::queue::pop
return value? – Stack Overflow
⚓
- std::queue – C++ reference
❔
- Priority queue clear method – Stack Overflow
⚓
- std::priority_queue – C++ reference
The class template
std::span
describes an object that can refer to a contiguous sequence of objects with the first element of the sequence at position zero. A span can either have a static extent or a dynamic extent.
🔗
- A.O’Dwyer.
std::span
should have a converting constructor frominitializer_list
(2021) - B.Revzin.
span
: the best span (2018) - B.Revzin. Should span be regular? (2018)
❔
- What is a
span
and when should I use one? – Stack Overflow - Why does
std::span
lackcbegin
andcend
methods? – Stack Overflow
🎥
- V.Ciura. A short life
span<>
for a regular mess – CppCon (2019)
⚓
std::span
– C++ reference- N.MacIntosh, S.T.Lavavej.
span
: bounds-safe views for sequences of objects – WG21/P0122 - C.Jabot, C.Carter. Range constructor for
std::span
– WG21/P1394 - T.Van Eerd. Should
span
be regular? – WG21/P1085 - T.Brindle. Usability enhancements for
std::span
– WG21/P1024 - J.Brown. Signed
ssize()
functions, unsignedsize()
functions – WG21/P1227 - R.Douglas, N.Liber, M.Clow. Sizes should only
span
unsigned – WG21/P1089
🎥
- N.Liber.
mdspan
: A deep dive spanning C++, Kokkos & SYCL – Core C++ (2023)
Transparent comparators make it possible to avoid constructing an object of the type
key_type
to do the lookup using member functions likefind
,lower_bound
, etc.
❔
- What are transparent comparators? – Stack Overflow
- Why is there no
std::is_transparent
equivalent for unordered containers? – Stack Overflow
⚓
- J.Wakely, S.T.Lavavej, J.M.López Muñoz. Adding heterogeneous comparison lookup to associative containers – WG21/N3657
🔗
- A.O’Dwyer. How to erase from an STL container (2020)
❔
- Is stability of
std::remove
andstd::remove_if
design fail? – Stack Overflow
⚓
- B.Friedman. Unstable remove algorithms – WG21/P0041
🔗
- unsigned integers – libtorrent blog (2016)
- D.Crocker. Danger – unsigned types used here! (2010)
❔
- Why is
std::ssize()
introduced in C++20? – Stack Overflow - Why are unsigned integers error prone? – Stack Overflow
🎥
- J.Kalb.
unsigned
: A guideline for better code – CppCon (2016)
⚓
- J.Brown. Signed
ssize()
functions, unsignedsize()
functions – WG21/P1227 - R.Douglas, N.Liber, M.Clow. Sizes should only
span
unsigned – WG21/P1089
🔗
See also Exceptions – Core language and Exceptions – Patterns, idioms, and design principles.
🔗
- A.O’Dwyer. What is the “vector pessimization”? (2022)
- A.O’Dwyer. A “pick two” triangle for
std::vector
(2022)
❔
- Why those two
std::string::find()
functions are declared asnoexcept
? – Stack Overflow - Why vector access operators are not specified as
noexcept
? – Stack Overflow
⚓
- A.Bergé. “Throws: Nothing” should be
noexcept
– WG21/P1656
⚓
- A.Krzemieński, T.Kamiński.
bad_alloc
is not out-of-memory! – WG21/P1404
🎥
- G.Davidson. File I/O: Past, present, and future – CppCon (2023)
❔
tellg()
function give wrong size of file? – Stack Overflow- Why does
std::getline()
skip input after a formatted extraction? – Stack Overflow - Why is
iostream::eof
inside a loop condition (i.e.while (!stream.eof())
) considered wrong? – Stack Overflow - Who architected/designed C++’s IO Streams, and would it still be considered well-designed by today’s standards? – Stack Overflow
⚓
- Input/output via
<iostream>
and<cstdio>
– C++ FAQ - Input/output library – C++ reference
🔗
- C.Sharpe. Don’t use
std::endl
– Overload 149 (2019) - D.Kühl. Stop excessive use of
std::endl
(2012)
⚓
std::endl
– C++ reference
🔗
- {fmt}: a modern formatting library
- S.Ignatchenko. 5 Reasons not to use
std::ostream
for human-readable output – Overload 143 (2018) - D.Epp. IOStream is hopelessly broken (2017)
- H.Sutter. The string formatters of manor farm (2001)
❔
std::printf
vs.std::cout
– Stack Overflow- Is
std::cout
synchronized/thread-safe? – Stack Overflow
🔗
- S.Collyer. C++20 text formatting: An introduction – Overload 166 (2021)
❔
- How can I use C++20
std::format
? – Stack Overflow
⚓
- V.Zverovich, L.Howes. Text formatting – WG21/P0645
❔
stringstream <<
“overwriting” – Stack Overflow
The class
std::ios_base::Init
is used to ensure that the default C++ streams (std::cin
,std::cout
, etc.) are properly initialized and destructed; the class tracks how many instances of it are created and initializes the C++ streams when the first instance is constructed as well as flushes the output streams when the last instance is destructed. The nifty counter idiom is typically used in implementations.
See also Iterator – Patterns, idioms, and design principles and Boost.Iterator – Applications.
🔗
- S.Dargo. C++ basics: Pointers vs iterators (2022)
- S.Meyers. Three guidelines for effective iterator usage – Dr.Dobb’s Journal (2001)
- K.Kreft, A.Langer. Iterators in the Standard C++ library – C++ Report (1996)
❔
const_iterator
and constness ofconst_iterator::value_type
– Stack Overflow- Why use iterators instead of array indices? – Stack Overflow
- Iterator loop vs index loop – Stack Overflow
- Why is
std::iterator
deprecated? – Stack Overflow
🎥
- N.Josuttis. Back to basics: Iterators in C++ – CppCon (2023)
- C.Carter. Iterator haiku – CppCon (2016)
❔
- Iterator vs reverse iterator – Stack Overflow
🔗
- T.Brindle. Rvalue ranges and views in C++20 (2020)
🎥
- J.Garland. Effective ranges: A tutorial for using C++2x ranges – CppCon (2023)
- T.Brindle. An overview of standard ranges – ACCU (2021)
- T.Brindle. C++20 ranges in practice – CppCon (2020)
- T.Brindle. An overview of standard ranges – CppCon (2019)
- A.Schödl. Why iterators got it all wrong and what we should use instead – CodeNode (2017)
- A.Schödl. From iterators to ranges: The upcoming evolution of the STL – Meeting C++ (2015)
❔
- Ranges
filter_view::iterator
element modification results in UB – Stack Overflow
🎥
- N.Josuttis. C++ views – ACCU (2023)
- N.Josuttis. Belle views on C++ ranges, their details and the devil – Meeting C++ (2022)
🎥
- N.Josuttis. Guide to the C++ filter view in C++ programming – CppCon (2024)
- N.Josuttis. Understanding the filter view to use it right – ACCU (2024)
- N.Josuttis. Using the filter view in practice – Meeting C++ (2023)
See also Memory – Optimization and hardware.
❔
- How is
malloc()
implemented internally? – Stack Overflow - Difference between
malloc
andcalloc
? – Stack Overflow
⚓
- R.10: Avoid
malloc()
andfree()
– C++ core guidelines
📖
- Ch. 3: Memory ownership – F.G.Pikus. Hands-on design patterns with C++ (2019)
❔
- What does (template)
rebind<>
do? – Stack Overflow - Why is
allocator::rebind
necessary when we have template template parameters? – Stack Overflow - Why is
std::allocator
a template? – Stack Overflow
🎥
- P.Halpern. Allocators: The good parts – CppCon (2017)
- B.Steagall. How to write a custom allocator – CppCon (2017)
⚓
std::allocator
– C++ reference
See also Boost.SmartPtr – Applications.
A smart pointer is a class that simulates a raw C++ pointer, and provides automatic exception-safe object lifetime management.
🔗
- R.Chen. Making sure that people use
make_unique
andmake_shared
to make your object (2022) - S.Dargo. Smart pointers and their deleters (2022)
- A.O’Dwyer. In praise of
make_unique
(2018) - H.Sutter. GotW #91: Smart pointer parameters – Guru of the Week (2013)
- Y.Sharon. Smart pointers: What, why, which? (1999)
❔
- What is a smart pointer and when should I use one? – Stack Overflow
- Why is
shared_ptr<void>
legal, whileunique_ptr<void>
is ill-formed? – Stack Overflow - Does
unique_ptr
andshared_ptr
able to convert to each other’s type? – Stack Overflow
🎥
- R.Grimm. Back to basics: Smart pointers – CppCon (2020)
- A.O’Dwyer. Back to basics: Smart pointers – CppCon (2019)
- M.Fleming. The smart pointers I wish I had – CppCon (2019)
- U.Drepper. C++ and memory: Between correctness and performance – code::dive (2018)
⚓
- Smart pointer – Wikipedia
The
std::unique_ptr
class is a smart pointer with unique ownership.std::unique_ptr<T>
is almost as cheap as a raw pointerT*
. For the Itanium ABI, any type with a destructor that is passed by value must be passed in memory: the address held in thestd::unique_ptr
must be written out to memory, rather than passed in registers as it would be for a raw T*
.
🔗
- A.Fertig. Using C++23s
constexpr
unique_ptr
(2023) - M.Clow. Simplifying code and achieving exception safety using
unique_ptr
(2015) - E.Bendersky. Using
unique_ptr
with standard library containers (2012) - A.Soffer. TotW #187:
std::unique_ptr
must be moved` – Abseil C++ Tips - Y.Mandelbaum. TotW #134:
make_unique
and private constructors` – Abseil C++ Tips - J.Dennett. TotW #126:
make_unique
is the newnew
` – Abseil C++ Tips
❔
- What to use
std::optional
orstd::unique_ptr
? – Stack Overflow - Should I assign or reset a
unique_ptr
? – Stack Overflow make_unique
with brace initialization – Stack Overflow- How do I pass a
unique_ptr
argument to a constructor or a function? – Stack Overflow - Why can a
T*
be passed in register, but aunique_ptr<T>
cannot? – Stack Overflow
⚓
std::unique_ptr
– C++ reference- S.T.Lavavej.
make_unique
– WG21/N3588 - A.Fertig. Making
std::unique_ptr
constexpr
– WG21/P2273
The
std::unique_ptr
class is a smart pointer with shared ownership.
🔗
- A.Williams.
std::shared_ptr
’s secret constructor (2015) - H.Kumar.
shared_ptr
initialized withnullptr
is null or empty? (2020)
❔
std::shared_ptr
exception safety – Stack Overflowstd::shared_ptr
thread safety – Stack Overflowshared_ptr
magic – Stack Overflow- How do I call
std::make_shared
on a class with only protected or private constructors? – Stack Overflow - What is the difference between an empty and a null
std::shared_ptr
in C++? – Stack Overflow
⚓
std::shared_ptr
– C++ reference
std::enable_shared_from_this
allows a member function of an object that is currently managed by astd::shared_ptr
to extend the lifetime of that object dynamically by generating additionalstd::shared_ptr
instances.
🔗
❔
- What is the usefulness of
enable_shared_from_this
? – Stack Overflow
⚓
std::enable_shared_from_this
– C++ reference
❔
- When is
std::weak_ptr
useful? – Stack Overflow
⚓
std::weak_ptr
– C++ reference
std::auto_ptr
is a smart pointer with unique ownership that had been designed before rvalue references and move semantics were introduced into the language. It was deprecated in C++11 and removed in C++17.
🔗
- H.Sutter. GotW #25:
auto_ptr
– Guru of the Week (2009)
⚓
std::auto_ptr
– C++ reference
std::observer_ptr
is a smart pointer that takes no ownership responsibility for its pointees (non-owning pointer).
⚓
std::experimental::observer_ptr
– C++ reference- B.Stroustrup. Abandon
observer_ptr
– WG21/P1408 - W.E.Brown. A proposal for the world’s dumbest smart pointer – WG21/N4282
std::out_ptr
andstd::inout_ptr
are a thing convertible to aT**
that updates (with areset()
call or semantically equivalent behavior) the smart pointer it is created with when it goes out of scope.
🔗
- S.Dargo. C++23:
std::out_ptr
andstd::inout_ptr
(2022)
❔
- Understanding
std::inout_ptr
andstd::out_ptr
in C++23 – Stack Overflow
🎥
- J.Erickson. Leveraging C++20/23 features for low level interactions – CppCon (2024)
⚓
std::out_ptr_t
– C++ referencestd::inout_ptr_t
– C++ reference- J.Meneide, T.Buyukliev, I.Muerte.
out_ptr
– a scalable output pointer abstraction – WG21/P1132
⚓
- E.J.Rosten, O.J.Rosten.
constexpr
for<cmath>
and<cstdlib>
– WG21/P0533
⚓
- Standard library header
<bit>
– C++ reference - V.Reverdy. On the names of low-level bit manipulation functions – WG21/P1956
⚓
std::bit_cast
– C++ reference- J.Bastien. Bit-casting object representations – WG21/P0476
🔗
- V.Reverdy. On vectors, tensors, matrices, and hypermatrices – WG21/P1770
- M.Hoemmen et al. Historical lessons for C++ linear algebra library standardization – WG21/P1417
🎥
- G.Davidson. A linear algebra library for C++23 – C++ on Sea (2019)
- G.Davidson. Standardizing a linear algebra library – Meeting C++ (2018)
⚓
- G.Davidson, B.Steagall. A proposal to add linear algebra support to the C++ standard library – WG21/P1385
- G.Davidson, B.Steagall. What do we need from a linear algebra library? – WG21/P1166
🔗
- M.E.O’Neill. Everything you never wanted to know about C++’s
random_device
– PCG (2015) - M.E.O’Neill. C++ seeding surprises – PCG (2015)
❔
- Why is the new random library better than
std::rand()
? – Stack Overflow - Why not just use
random_device
? – Stack Overflow - Is uninitialized local variable the fastest random number generator? – Stack Overflow
🎥
- F.Buontempo. What is a random number and why should I care – Meeting C++ (2023)
- A.Weis. Random numbers are hard – Meeting C++ (2019)
- W.E.Brown. What C++ programmers need to know about header
<random>
– CppCon (2016) - C.Marks. I just wanted a random integer! – CppCon (2016)
- S.T.Lavavej.
rand()
considered harmful – GoingNative (2013)
❔
- Random engine differences – Stack Overflow
- How to succinctly, portably, and thoroughly seed the
mt19937
PRNG? – Stack Overflow - If we seed
mt19937
as the same on different machines, will we get the same sequence of random numbers? – Stack Overflow
⚓
- M.Klammler. Efficient seeding of random number engines – WG21/P0205
- P.Dyakov, I.Burylov, R.Arutyunyan, A.Nikolaev. Extension of the C++ random number generators – WG21/P1932
See Randomized algorithms and probabilistic data structures – Distributions.
⚓
- M.Hořeňovský. Make pseudo-random numbers portable – WG21/P2059
- M.Paterno. On random-number distributions for C++0x – WG21/N1588
- W.E.Brown. LWG issue 2168 is NAD – WG21/N3926
🔗
- Regular expressions library – C++ reference
🎥
- T.Shen. Regular expressions in C++, present and future – CppCon (2016)
This class holds implementation-specific information about a type, including the name of the type and means to compare two types for equality or collating order. This is the class returned by the
typeid
operator.
❔
- Unmangling the result of
std::type_info::name
– Stack Overflow
⚓
std::type_info
– C++ reference
std::nullptr_t
is the type of the null pointer literalnullptr
. It is a distinct type that is not itself a pointer type or a pointer to member type. An object of this type can be converted to any pointer or pointer-to-member type by a standard conversion.
🔗
nullptr
– WikiBooks
❔
- How does
nullptr
implementation work? – Stack Overflow - Why is
nullptr
a part of the core language, butnullptr_t
is a part of STL? – Stack Overflow - Is
nullptr
falsy? – Stack Overflow
⚓
std::nullptr_t
– C++ reference- H.Sutter, B.Stroustrup. A name for the null pointer:
nullptr
– WG21/N2431
std::int8_t
,std::int16_t
,std::int32_t
, andstd::int64_t
are guaranteed to use 2’s complement to represent negative values. They are provided only if the implementation directly supports the type.
🔗
- S.Ignatchenko. C++: On using
int*_t
as overload and template parameters (2018)
❔
- When is
uint8_t
≠unsigned char
? – Stack Overflow size_t
vsuintptr_t
– Stack Overflow- Is
intmax_t
the same aslong long int
? – Stack Overflow
std::aligned_storage
defines the type suitable for use as uninitialized storage for types of given size,aligned_union
defines the type suitable for use as uninitialized storage for all given types.
❔
- What is the purpose of
std::aligned_storage
? – Stack Overflow - Placement new in
std::aligned_storage
? – Stack Overflow
⚓
- C.J.Johnson. Deprecate
std::aligned_storage
andstd::aligned_union
– WG21/P1413
⚓
std::byte
– C++ reference- N.MacIntosh. A byte type for increased type safety – WG21/P0257
See also Type traits – Templates.
📝
- There 14 primary type categories:
is_void
,is_null_pointer
,is_integral
,is_floating_point
,is_array
,is_enum
,is_union
,is_class
,is_function
,is_pointer
,is_lvalue_reference
,is_rvalue_reference
,is_member_object_pointer
,is_null_pointer
. Each type belongs to exactly one of them.
🎥
- M.Clow. Type traits: What are they and why should I use them? – CppCon (2015)
⚓
- Standard library header
<type_traits>
– C++ reference
❔
- How does this implementation of
std::is_class
work? – Stack Overflow
❔
- How does
is_base_of
work? – Stack Overflow
🎥
- J.Turner. Great C++
is_trivial
– CppCon (2019)
🔗
- R.Chen. What’s the deal with
std::type_identity
? (2024)
⚓
std::type_identity
– C++ reference- T.Doumler. The identity metafunction – WG21/P0887
- J.Yasskin. The identity type transformation – WG21/N3766
🔗
- Utility library – C++ reference
Integer comparison functions std::cmp_equal
, std::cmp_not_equal
, std::cmp_less
, std::cmp_greater
, std::cmp_less_equal
, std::cmp_greater_equal
compare the values of two integers; unlike builtin comparison operators, negative signed integers always compare less than (and not equal to) unsigned integers: the comparison is safe against lossy integer conversion.
⚓
- Integer comparison functions – C++ reference
- F.Kircheis. Safe integral comparisons – WG21/P0586
🎥
- S.T.Lavavej.
<functional>
: What’s new, and proper usage – CppCon (2015)
⚓
- Function objects – C++ reference
std::reference_wrapper
is a class template that wraps a reference in a copyable, assignable object; it can be used as a mechanism to store references inside standard containers, which cannot normally hold references.
🎥
- Z.Yuan. The many shades of
reference_wrapper
- CppCon (2020)
⚓
std::reference_wrapper
– C++ reference
An object of type
std::initializer_list<T>
is a lightweight proxy object that provides access to an array of objects of typeconst T
.
❔
initializer_list
and template type deduction – Stack Overflowstd::initializer_list
and move semantics – Stack Overflow
⚓
std::initializer_list
– C++ reference
🎥
- A.O’Dwyer. Back to basics: Algebraic data types – CppCon (2020)
❔
- Why can’t
std::tuple<int>
be trivially copyable? – Stack Overflow - Replace
N
-th element of astd::tuple
– Stack Overflow - How does
std::tie
work? – Stack Overflow
🎥
- A.Meredith. How C++20 can simplify
std::tuple
– ACCU (2019) - S.T.Lavavej.
tuple<>
: What’s new and how it works – CppCon (2016)
The class template
std::optional<T>
is a type that may or may not store a value of typeT
in its storage space. It is recommended to be used in situations where there is exactly one and clear reason for having no value of typeT
, and where the lack of value is as natural as having any regular value ofT
. It is not recommended to use optional to indicate that we were not able to compute a value because of a failure.
🔗
- A.Krzemieński. A moved-from optional (2022)
- B.Filipek. Using C++17
std::optional
(2018) - B.Filipek. Error handling and
std::optional
(2018) - B.Filipek. In-place construction for
std::any
,std::variant
andstd::optional
(2018) - B.Revzin. Implementing the spaceship operator for
optional
– Overload 147 (2018) - S.Brand. Functional error-handling with optional and expected – Overload 143 (2018)
- S.Brand. Functional exceptionless error-handling with optional and expected (2017)
- S.Brand. Implementation with functional-style extensions and reference support
- A.Krzemieński. Efficient optional values (2015)
- A.Krzemieński. A gotcha with Optional (2014)
❔
- What to use:
std::optional
orstd::unique_ptr
? – Stack Overflow - Implementing
operator<=>
foroptional<T>
– Stack Overflow - Difference between Boost.Optional and
std::experimental::optional
assignment – Stack Overflow
⚓
std::optional
– C++ reference- Boost.Optional: The optional wrapper library
- F.Cacciola, A.Krzemieński. A proposal to add a utility class to represent optional objects – WG21/N3793
- M.Mutz. More flexible
optional::value or()
– WG21/P2218 - A.Krzemieński. N3793 reference implementation
🔗
- A.Fertig. Visiting a
std::variant
safely (2023) - J.Müller. Technique: Recursive variants and boxes (2022)
- A.Williams. Standardizing
variant
: Difficult decisions (2015)
❔
🎥
- R.Barkan. Variations on variants – C++Now (2021)
- N.Liber. The many variants of
std::variant
– C++Now (2019) - M.Pusz. Effective replacement of dynamic polymorphism with
std::variant
– ACCU (2019) - M.Pusz. Effective replacement of dynamic polymorphism with
std::variant
– CppCon (2018) - D.Sankel. Variants: Past, present, and future – CppCon (2016)
⚓
std::variant
– C++ reference- A.Naumann. Variant: a type-safe union – WG21/N4542
- Y.Zhihao. A sane
variant
converting constructor – WG21/P0608
See also Type erasure – Patterns, idioms, and design principles.
🔗
- C.Carter.
std::any
: How, when, and why (2018)
⚓
std::any
– C++ reference
A utility class to represent expected monad.
🔗
- S.Brand. Functional error-handling with optional and expected – Overload 143 (2018)
- S.Brand. C++11/14/17
std::expected
with functional-style extensions
🎥
- N.Douglas. Introduction to proposed
std::expected
– Meeting C++ (2017)
⚓
- V.Botet, J.Bastien.
std::expected
– WG21/P0323 - N.Douglas. Concerns about
expected<T, E>
from the Boost.Outcome peer review – WG21/P0762 - V.Botet, P.Talbot. A proposal to add a utility class to represent expected monad – WG21/N4109
❔
- What is the purpose of
std::launder?
– Stack Overflow - Where can I find what
std::launder
really does? – Stack Overflow
⚓
std::launder
– C++ reference
🔗
❔
std::experimental::source_location
at compile time – Stack Overflow- How to use source_location in a variadic template function? – Stack Overflow
⚓
std::source_location
– C++ reference- R.Douglas, C.Jabot, D.Krügler, P.Sommerlad. Adopt
source_location
for C++20 – WG21/P1208
🔗
- A.Krzemieński. Using
std::chrono
(2022) - A.Krzemieński. Local time (2022)
❔
- Accepting
std::chrono::duration
of any representation/period – Stack Overflow - What are the uses of
std::chrono::high_resolution_clock
? – Stack Overflow
🎥
- H.Hinnant. A
<chrono>
tutorial – CppCon (2016) - H.Hinnant. A C++14 approach to dates and times – CppCon (2015)
⚓
- Date and time utilities – C++ reference
- H.E.Hinnant, W.E.Brown, J.Garland, M.Paterno. A foundation to sleep on: Clocks, points in time, and time durations – WG21/N2661
❔
- Native path separator bug in C++17
std::filesystem::path
? – Stack Overflow - What is the C++17 equivalent to
boost::filesystem::unique_path()
? – Stack Overflow
⚓
- Filesystem library – C++ reference
🔗
- A.O’Dwyer. Don’t inherit from standard types (2018)
❔
- In
std::exchange
, why is the second template parameter defaulted? – Stack Overflow - Why does the C++ standard algorithm
count
return adifference_type
instead ofsize_t
? – Stack Overflow - Why standard container iterators don’t overload
->*
? – Stack Overflow - Why does
numeric_limits
work on types it does not know? – Stack Overflow - Why is swap called by
std::sort
only if my container has more than 32 elements? – Stack Overflow
🎥
- J.Brown. This one weird trick:
std::integral_constant
– CppCon (2019) - B.Fahller. My favourite memory leak – Meeting C++ (2023)
🔗
- E.Niebler. *Post-conditions on self-move (2017)
❔
- What does the standard library guarantee about self move assignment? – Stack Overflow
- What is the rationale for self-assignment-unsafe move assignment operators in the standard library? – Stack Overflow
🔗
- D.Levin. glibc: The C library in GNU/Linux system – OS Day (in Russian, 2018)
- J.Wakely. Why
<cstdlib>
is more complicated than you might think (2016)
⚓
- W.E.Brown. Deprecate certain declarations in the global namespace – WG21/P0657
🔗
- Standard Template Library – Wikipedia
- History of the Standard Template Library – Wikipedia
❔
- What’s the difference between “STL” and “C++ standard library”? – Stack Overflow
📖
- M.J.Vilot. Standard template library – S.B.Lippman. C++ gems: Programming pearls from The C++ report (1997)
📄
- D.R.Musser, A.A.Stepanov. A library of generic algorithms in Ada – Proceedings of ACM SIGAda, 216 (1987)
🎥
⚓