std::remove — logical element removal
std::remove moves retained elements to the front of a range and returns its new logical end. It does not shrink the container; use erase to actually remove the trailing elements.
CKTIS / C++
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
std::remove moves retained elements to the front of a range and returns its new logical end. It does not shrink the container; use erase to actually remove the trailing elements.
std::remove_if moves retained elements to the front of a range and returns its new logical end. It does not change the container's size; for std::vector, erase completes the removal.
std::replace from <algorithm> replaces every occurrence of a specified value within an iterator range. It modifies existing elements, preserves the container's size, and returns void.
std::replace_if from <algorithm> replaces elements satisfying a predicate in place with one supplied value. It preserves the number of elements and returns void.
std::reverse from <algorithm> reverses the elements of [first, last) in place. It requires bidirectional iterators and elements that can be swapped, and returns void.
std::reverse_iterator::base returns a copy of the stored underlying iterator. Its position is one element farther in the forward direction than the element accessed through the reverse iterator.
std::right sets right alignment on an output stream: padding characters appear before the value. The setting persists, while the field width is specified separately, for example with std::setw.
std::rotate from <algorithm> rearranges a range in place: the part starting at middle moves before the part starting at first. It preserves order within both parts and returns an iterator to their new boundary.
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.