std::distance: counting steps between iterators
std::distance returns the number of increments needed to reach last from first, using subtraction for random-access iterators.
CKTIS / Knowledge base
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
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.
std::filesystem::copy copies a file, symlink, or directory according to the source type and copy_options bits, reporting errors by exception or error_code.
std::filesystem::create_directories creates missing directories along a path in order and reports whether it created the final directory.
std::filesystem::directory_iterator is an input iterator over a directory’s immediate entries and does not descend into subdirectories automatically.
std::filesystem::exists returns true when a path status is known and is not file_type::not_found.
std::filesystem::file_size returns a uintmax_t regular-file size in bytes and reports an error for a missing path.
std::filesystem::path stores pathname syntax and elements but does not itself check whether a filesystem object exists or is valid.
std::filesystem::perms represents file permission bits. Combine flags with |, inspect them with &, and distinguish an empty permission set from unknown permissions.
std::filesystem::recursive_directory_iterator is a single-pass input iterator over entries in a directory and its subdirectories.