Archives

C++ lvalues, rvalues, and rvalue references

Understanding lvalues and rvalues is fundamental in modern C++. These concepts, which originated from the idea of what can appear on the “left” vs “right” side of an assignment, have evolved into a system that enables powerful techniques like move semantics and forwarding. The evolution of value categories In early C, the distinction was simple: […]

Read More

Writing safer C++ code with concepts

Concepts in C++20 provide a clean way to express what types your templates expect. This makes template code more readable and helps catch type errors at compile time, rather than during debugging. In this example, Printable is a concept that checks if a type can be used with std::cout. The print function can only be […]

Read More