std::counting_semaphore: limiting concurrent access
std::counting_semaphore maintains a permit count; acquire consumes a permit, while release returns permits and can unblock a waiter.
CKTIS / C++
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
std::counting_semaphore maintains a permit count; acquire consumes a permit, while release returns permits and can unblock a waiter.
std::cout is an output-stream object declared in iostream. The << operator sends it values, using formatting appropriate to their types.
std::current_exception from <exception> returns a std::exception_ptr referring to the currently handled exception or a copy. It lets you retain an exception and rethrow it later; with no handled exception, it returns a null value.
std::dec selects base 10 for formatted integer output and input in a C++ stream. The change remains active for subsequent operations until the stream's numeric base setting is changed again.
std::decay transforms a type at compile time to model pass-by-value. std::decay_t exposes the resulting type without writing ::type.
std::declval from <utility> lets you inspect an expression's type without constructing an object. Use it in unevaluated operands, such as decltype; it must not be used for an actual evaluated call.
std::default_sentinel_t is an empty range-end marker type from <iterator>. It works with iterators that can determine the end themselves, such as std::counted_iterator. It is not a universal replacement for end().
std::deque provides fast operations at both ends and random access, but contiguous storage for all of its elements is not guaranteed.
std::distance returns the number of increments needed to reach last from first, using subtraction for random-access iterators.
std::enable_if exposes a type only when a compile-time condition is true. The std::enable_if_t alias shortens the spelling; in an appropriate substitution context, it lets SFINAE remove candidates from overload resolution.
std::enable_shared_from_this lets an object obtain a shared_ptr that uses the same control block as its current owner.
std::end returns a container’s past-the-end iterator or a pointer one element beyond a built-in array.
std::endian from <bit> describes the byte order of scalar types in the execution environment. Compare native with little and big, while also handling the special cases.
std::endl inserts a newline and calls flush() on an output stream. Unlike '\n', it explicitly requests buffer synchronization; use it when you need both operations.
std::equal_range returns a pair of iterators enclosing every element equivalent to a searched value in an ordered range.
std::equal_to from <functional> wraps operator ==. The typed T form returns bool, while std::equal_to<> deduces both argument types.
std::erase removes every element equal to a supplied value from a supported sequence container or string and returns the removal count.
std::erase_if tests elements of a supported container, erases those for which the predicate is true, and returns the removal count.
std::errc is a scoped enumeration from <system_error>. It distinguishes named error conditions, including invalid_argument and result_out_of_range. With std::from_chars, check both ec and ptr when the entire input must be consumed.
std::error_code stores an integer value and a category that gives the value meaning and produces its message.
std::exception is the base of standard run-time exceptions; its virtual what() returns an implementation-defined null-terminated description without throwing.
std::exchange moves an object’s current value into the result, assigns a new value to the object, and returns the saved old state.
std::exclusive_scan writes, for every position, a reduction of the initial value and earlier elements, excluding the element at that position.
std::expected<T, E> holds exactly one of two states: an expected T value or an E error object, with no empty state.