Partitioned search range
`std::lower_bound` does not need a fully sorted range: for the given key, all elements that pass its test must come before all elements that fail it.
CKTIS / C++
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
`std::lower_bound` does not need a fully sorted range: for the given key, all elements that pass its test must come before all elements that fail it.
Construct an object in a prepared slot, manage its lifetime separately from the storage, and make the slot owner explicitly non-copyable and non-movable.
Learn how ISO C++23 uses `*` to declare pointers, where to put `const`, and how to distinguish a pointer to an array from an array of pointers.
`&C::m` can identify a non-static member without choosing an object. Apply the resulting member pointer to an object or use it as a projection in a ranges algorithm.
Separate caller obligations from valid object state. Validate external input independently of `assert`, and design the type’s public interface to preserve its invariant.
Since C++17, a same-type class prvalue constructs the result directly, without copying or moving the whole object. NRVO is optional, and member initialization can still copy data.
Use `= 0` to declare a pure virtual member function and define an abstract interface. Calls through that interface can select different implementations based on the object's type.
Use `|` to apply an adaptor closure to a range or compose two closures into a reusable pipeline. This overload is distinct from built-in bitwise OR.
Use `resize` to change how many elements exist. Use `reserve` to make room for future elements without changing the current size or contents.
Use `auto [it, inserted]` to name the iterator and insertion flag returned by `std::map::insert` when inserting a single value without a position hint.
The `&&` declarator forms an rvalue reference type. Overload resolution still depends on expression category: the name of a variable declared `T&&` is an lvalue when passed as an argument.
These three patterns separate object identity and lifetime, the choice of which implementation to construct, and the addition of behavior behind an unchanged interface.
C++23 specifies storage duration and object lifetime rules, not physical placement. An automatic object can contain a `std::string` that dynamically allocates character storage.
Learn how to read names such as `std::cout` and `std::chrono::seconds`, make declarations available, and shorten names safely. Curriculum examples show what the namespace controls and what comes from each API’s own contract.
In C++23, this deprecated overload atomically copies a `std::shared_ptr` and lets you choose the memory order of the load.
The legacy overload publishes a std::shared_ptr with a release store and pairs with an acquire load. It is still in C++23; prefer std::atomic<std::shared_ptr<T>> in new code.
`setf` changes a stream's formatting flags. Use `std::ios::boolalpha` to print `bool` values as `true` and `false` in the classic locale.
Choose the `append` overload that matches your source: a whole string, a slice, or a buffer with a known length. Add separators explicitly and preserve embedded nulls.
Choose the overload that matches your source. For a buffer with a known length, pass a pointer and a count to preserve embedded null characters.
Build a string containing exactly `count` copies of `ch`. Use parentheses to select the fill overload rather than the initializer-list overload.
Pair `data()` with `size()` to preserve embedded zeros, and check the string’s bounds and lifetime before using the pointer.
Find the first match at or after a starting position, check for `npos`, and use an explicit pattern length when a buffer may contain embedded nulls.
Test a `find` result against `npos` before using it as an index. In the count parameter of `substr`, the same constant means to take the rest of the string.
Append one code unit to a string, directly or through an output iterator. Learn what growth can invalidate and how to preserve embedded nulls in bounded data.