Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Knowledge base

Knowledge base

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

Entries: 5788

C++

std::string::find — first match and npos

Find the index of a character or substring and compare it with `std::string::npos` before using it as an index or copying or changing the text.

Advanced · ISO C++23; implementation support may vary
C++

`std::string::npos`: no match or a count to the end

Compare the result of `std::string::find` with `std::string::npos`. As a count in `substr` or `erase`, the same constant means “through the end,” not a starting position.

Advanced · ISO C++23; implementation support may vary
C++

std::vector::back — access the last element

Use `back()` to read or change the last element of a non-empty vector. Know when the result becomes invalid and why extracting an element from a heap takes two separate steps.

Advanced · ISO C++23; implementation support may vary
C++

std::vector::begin — start of a vector range

`begin()` returns the vector's starting iterator. The vector's constness selects the overload, and `end()` marks the position you must not dereference.

Advanced · ISO C++23; implementation support may vary
C++

std::vector::end — past-the-end iterator

`std::vector::end` returns the position just past the last element, not the last element itself. Use it as an exclusive range boundary and to detect a failed search.

Advanced · ISO C++23; implementation support may vary
C++

std::vector::insert — insert elements into a vector

Insert a value, repeated copies, an initializer list, or an iterator range before a chosen position. Use the returned iterator and know which existing handles become invalid.

Advanced · ISO C++23; implementation support may vary
C++

std::vector::pop_back — Remove the last element

`pop_back()` removes the last element of a non-empty vector without returning its value. For a vector that stores a heap, `std::pop_heap` rearranges the elements; `pop_back()` reduces the size.

Advanced · ISO C++23; implementation support may vary
C++

std::vector::push_back — appending one element

Append one element by copying or from an rvalue. Learn when growth invalidates pointers and why the old `end()` is invalid even when no reallocation occurs.

Advanced · ISO C++23; implementation support may vary
C++

std::vector::swap — exchanging two vectors

Exchange two vectors’ contents and capacities in constant time. Check allocator compatibility and learn which iterators remain usable after the swap.

Advanced · ISO C++23; implementation support may vary
C++

Array `new[]` and `delete[]` vs. single-object forms

Use `delete` for an object created with `new T` and `delete[]` for an array created with `new T[n]`. These expressions manage object lifetimes; the corresponding `operator new` and `operator delete` functions, with or without `[]`, manage storage.

Intermediate · ISO C++23; implementation support may vary