Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C++

Knowledge base — C++

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 674

C++

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.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::remove_if — logical removal by predicate

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.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::replace — replace values in place

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.

Basic · C++23; repository compiler flag, production runtime not attested
C++

std::replace_if — replace elements matching a condition

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.

Basic · C++23; repository compiler flag, production runtime not attested
C++

std::reverse — reversing element order

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.

Basic · C++23; repository compiler flag, production runtime not attested
C++

std::reverse_iterator::base — the underlying iterator

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.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::right — right-align an output field

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.

Basic · C++23; repository compiler flag, production runtime not attested
C++

std::rotate — cyclically rearrange a range

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.

Basic · C++23; repository compiler flag, production runtime not attested
C++

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.

Basic · C++23; repository compiler flag, production runtime not attested
C++

std::scoped_lock — scope-bound lock ownership

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.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::set — an ordered collection of unique keys

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.

Basic · C++23; repository compiler flag, production runtime not attested
C++

std::set_difference — difference of sorted ranges

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.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::setfill — output field fill character

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.

Basic · C++23; repository compiler flag, production runtime not attested
C++

std::set_intersection — intersection of sorted ranges

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.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::setprecision — numeric formatting precision

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.

Basic · C++23; repository compiler flag, production runtime not attested
C++

std::set_symmetric_difference — symmetric difference of sorted ranges

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.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::set_union — union of sorted ranges

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.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::setw — setting stream field width

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.

Basic · C++23; repository compiler flag, production runtime not attested
C++

std::shared_future — shared access to a result

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.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::shared_lock — managing shared lock ownership

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.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::shared_mutex — shared and exclusive locking

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.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::shared_ptr — shared ownership

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.

Intermediate · C++23; repository compiler flag, production runtime not attested
C++

std::shuffle — randomly rearranging elements

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.

Basic · C++23; repository compiler flag, production runtime not attested
C++

std::sort: ordering a range

std::sort, declared in algorithm, rearranges elements of a range. It requires random-access iterators and a comparison that establishes a strict weak ordering.

Basic · C++23