std::runtime_error — runtime error exception
std::runtime_error, declared in <stdexcept>, reports errors detectable during program execution. It carries a message accessible through what() and publicly derives from std::exception.
CKTIS / Knowledge base
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
std::runtime_error, declared in <stdexcept>, reports errors detectable during program execution. It carries a message accessible through what() and publicly derives from std::exception.
std::scoped_lock owns mutex locks for its object's lifetime. Its constructor locks the supplied mutexes, and its destructor unlocks them. For multiple mutexes, it uses std::lock to avoid deadlock while acquiring them together.
std::set from <set> stores unique keys in comparator order. Learn insertion, lookup, and the differences between find, contains, count, and equal_range, including how to check end() safely.
std::set_difference copies the difference of two sorted ranges into a separate destination. It accounts for duplicates: each equivalent occurrence in the second range cancels one occurrence from the first range's result.
std::setfill from <iomanip> sets the character used to pad fields during formatted output. It works with a field width, for example one set by std::setw, and its setting remains active until changed again.
std::set_intersection copies the common elements of two sorted ranges to a separate destination. It retains duplicates according to the smaller occurrence count, rather than producing only unique values.
std::setprecision from <iomanip> sets a stream's precision. With std::defaultfloat, a positive precision sets the maximum number of significant digits. With std::fixed and std::scientific, a nonnegative precision sets the number of digits after the decimal separator, while a negative precision gives the default of six. The setting remains active for subsequent operations.
std::set_symmetric_difference writes the sorted symmetric difference of two sorted ranges. It accounts for duplicate counts, accepts an output iterator, and returns an iterator past the elements written.
std::set_union writes the sorted union of two sorted ranges. It preserves the maximum occurrence count of equivalent elements across the inputs, so the result does not necessarily contain only unique values.
std::setw(n), declared in <iomanip>, sets a stream's field width. On output, shorter values are padded and longer values are not truncated. Reapply the width for successive fields because output operations can reset it.
std::shared_future lets multiple consumers access one result or exception. It is copyable and supports repeated get() calls; wait() waits for readiness, while wait_for() checks readiness with a timeout.
std::shared_lock from <shared_mutex> manages shared lock ownership using RAII. It supports concurrent reading by multiple threads, but does not provide the exclusive ownership needed to modify shared data.
std::shared_mutex lets multiple threads hold shared ownership simultaneously or one thread hold exclusive ownership. Use std::shared_lock for reading and std::unique_lock for writing, following the same protocol for every access to the protected data.
std::shared_ptr<T> from <memory> shares ownership of an object. Copies keep it alive, and releasing the last owner triggers cleanup. std::weak_ptr observes the object without extending its lifetime.
std::shuffle rearranges a range in place using a supplied random number generator. It requires random-access iterators; a fixed seed does not guarantee the same ordering across different standard-library implementations.
std::sort, declared in algorithm, rearranges elements of a range. It requires random-access iterators and a comparison that establishes a strict weak ordering.
std::sort_heap turns a heap into a sorted range. It requires random-access iterators and a range that is a valid heap under the comparison the function uses; it does not sort arbitrary input directly.
std::span provides access to contiguous elements without owning them. It lets you pass a range together with its size, while subspan creates a view of part of that range without copying elements.
std::stable_partition rearranges a range so that elements satisfying a predicate precede the others. It preserves relative order within both groups and returns an iterator to the partition boundary.
std::stable_sort sorts a range while preserving the relative order of elements equivalent under the comparison. It lets you order records by a key without changing the previous order of records with the same key.
std::stack from <stack> provides a LIFO stack: the most recently added element is removed first. The adaptor supports adding elements, inspecting the top, and removing it, but exposes neither iterators nor indexed access.
std::stod from <string> converts a numeric prefix of text to double. The optional idx parameter identifies where conversion stopped; remaining characters do not automatically cause an error.
std::stoi from <string> converts an initial portion of text to int. It lets you specify the numeric base and retrieve the position where conversion stopped. It does not require consuming the entire string and reports errors through exceptions.
std::stop_source provides shared stop-request state. get_token() exposes that state for observation, while request_stop() requests stopping. This is a cooperative mechanism: it does not automatically interrupt a running thread.