std::stop_token — cooperative operation cancellation
std::stop_token lets an operation check whether a stop request has been made. Its stop_requested() member reads shared state; the token itself neither stops a thread nor issues a request.
CKTIS / Knowledge base
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
std::stop_token lets an operation check whether a stop request has been made. Its stop_requested() member reads shared state; the token itself neither stops a thread nor issues a request.
std::string is an owning, variable-length sequence of char elements. Learn construction, appending, searching, and substring extraction, including the difference between reserve and resize and the rules for safely using data().
std::stringstream from <sstream> formats values as text and reads values from text held in memory. It combines the << and >> operators with a string buffer and stream error state.
std::string_view provides access to text without copying characters or owning their storage. Learn to search with find, create subviews with substr, and check npos while keeping the underlying data alive.
std::strong_ordering from <compare> describes a three-way comparison result: less, equal, or greater. It represents a total order with substitutability of equal values and has no unordered state.
std::suspend_always from <coroutine> is a simple awaitable that suspends a coroutine without producing a value. It does not schedule resumption: managing code must retain a handle and resume or destroy the suspended coroutine.
std::suspend_never from <coroutine> is a trivial awaiter that does not suspend a coroutine and produces no value. It helps specify immediate coroutine startup or completion; at completion, careful attention to coroutine-state lifetime is necessary.
std::swap from <utility> exchanges the values of two objects and returns void. Learn the primary template's requirements, the array overload, and the call pattern that enables ADL in generic code.
std::system_error combines an error code with diagnostic text. It lets low-level errors travel as exceptions while retaining structured information for identifying the cause programmatically.
std::terminate, declared in <exception>, invokes a program-termination handler and never returns. It is triggered by conditions such as an unhandled exception or an exception escaping a noexcept function, and can also be called explicitly. It does not guarantee destructor-based resource cleanup.
std::this_thread::sleep_for blocks the calling thread for a relative interval expressed as std::chrono::duration. It neither creates a thread nor synchronizes access to data. Returning may take longer than the requested interval.
std::this_thread::yield() gives the implementation an opportunity to reschedule threads. It guarantees neither that another thread runs nor any particular waiting time, and it provides no memory synchronization.
std::thread runs a callable in a separate thread. Learn how joinable(), join(), and detach() differ, and why the association with a thread must be resolved before its object is destroyed.
std::tie from <tuple> creates a tuple of lvalue references to existing objects. It lets you assign tuple elements to variables and skip selected positions with std::ignore, without copying the referenced objects.
std::to_chars writes a number's textual representation into a caller-provided buffer. Its result contains an end pointer and an error code; the function does not append a terminating '\0'.
std::tolower from <cctype> converts one character to lowercase according to the current C locale. For char data, convert to unsigned char first and call the function only if the resulting value fits in int.
std::to_string from <string> returns a number's textual representation as a std::string. This entry covers C++23, including floating-point formatting limitations and the distinction from the newer working draft.
std::to_underlying, declared in <utility>, converts an enumeration value to its exact underlying type. Available since C++23, it is constexpr and noexcept; it neither forces the result to int nor checks whether the value corresponds to a named enumerator.
std::toupper from <cctype> returns a character's uppercase equivalent using the current C locale. Its argument must equal EOF or be representable as unsigned char; its return type is int.
std::transform from <algorithm> writes the results of a unary or binary operation into an output range. It neither creates a container nor automatically increases its size.
std::transform_reduce from <numeric> transforms elements of one range or corresponding pairs from two ranges, then combines the results with init. The reduction order and grouping are unspecified.
std::tuple from <tuple> groups a fixed number of elements whose types may differ. std::get provides access, while structured bindings let you give the elements local names.
std::u8string is an alias for std::basic_string<char8_t> from <string>. It stores UTF-8 code units but does not validate the encoding; size() does not count user-perceived characters.
std::unexpected<E> from <expected> wraps an error value to construct std::expected<T, E> in its failure state. It distinguishes an error from a successful result even when T and E are the same type.