Unary plus: converting a lambda to a function pointer
`+hardPass` uses unary `+` to convert a captureless, non-generic lambda to a function pointer. It does not perform addition.
CKTIS / C++
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
`+hardPass` uses unary `+` to convert a captureless, non-generic lambda to a function pointer. It does not perform addition.
Learn how C++23 selects class-specific `operator new` and `operator delete` overloads and why the paired global calls must receive the same alignment value.
The `[]` declarator forms a built-in array type. The bound can be part of the array type, but array syntax in a function parameter does not pass a length.
AoS stores complete records side by side, whereas SoA groups each field into its own array. Which layout fits depends on how the program accesses the data.
`assert` checks an internal program assumption at runtime. Defining `NDEBUG` can disable the check without evaluating its condition; it does not affect `static_assert`.
Distinguish an object’s storage duration and lifetime from any separate allocations made by its members, such as storage for a `std::string`’s characters.
Choose a data layout based on what the program actually reads. AoS groups the fields of a record; SoA groups values of the same field across records.
Capture a threshold by value so the predicate keeps using it even when the original variable changes.
`%F` prints the date and `%R` prints hours and minutes in 24-hour format. They format the value you pass; time-zone rules belong to the conversion step.
`extern "C"` specifies language linkage for interoperability between C and C++. It does not switch the compiler to C or guarantee binary compatibility on its own.
Separate storage management from object lifetime, choose the alignment-aware overloads, and forward the same alignment to the matching global functions.
Returning by value does not necessarily copy an object. Distinguish optional NRVO for a named local from guaranteed direct construction from a same-type prvalue.
Set `std::cout` to fixed-point notation with two digits after the decimal separator. Learn why the `floatfield` mask matters and how to restore the previous format.
A standalone ellipsis in `test(...)` provides a fallback overload when a typed probe cannot match. It is not a template parameter pack or pack expansion.
Choose a layout around how your program uses its data: compare whole records with separate columns, then measure the effect on a representative workload.
`= default` asks the compiler to supply the standard definition of an eligible function. Ownership, PImpl, and virtual destructors show where this matters.
Declare a public virtual base-class destructor so a derived object can be deleted through a base pointer without writing a destructor body for the base class.
In C++23, `= default` asks the compiler for the standard definition of a special member function. Definition placement matters in Pimpl; C++23 implementation support may vary.
`Product() = default;` explicitly declares a default constructor and lets the compiler implement it. The `default:` label in a `switch` marks where execution starts when no `case` matches.
Declare a pointer to a non-static `int` data member and a pointer to a `const` member function. See how the declared type selects an overload and how to use either pointer with an object.
`= delete` forbids use of a function at compile time. A coroutine frame owner can use it to forbid copying while still transferring ownership by moving and releasing the frame in its destructor.
Reject a specific overload or prevent copying at compile time while keeping a class movable and handling destruction of its hidden implementation correctly.
`= delete` makes a specific function unusable at compile time. Use it to reject an unwanted overload or to prevent an owning pool from being copied or moved.
A destructor marks the end of an object's lifetime and cleans up its resources. Learn how an owner destroys a coroutine frame and why a PImpl destructor is defined out of line.