Skip to main content

Posts

Effective Modern C++ notes

Effective Modern C++ (Scott Meyers) — Item-by-Item Interview Notes Each item: Gist (what it says), Why (the reasoning), Interview angle (what to be ready to explain). Chapter 1: Deducing Types Item 1: Understand template type deduction Gist: For template<typename T> void f(ParamType param); f(expr); the deduced T depends on the form of ParamType . Three cases: Reference/pointer (not universal): ignore expr's reference-ness, then pattern-match. Constness of the argument is preserved in T ( f(T&) with a const int gives T = const int ). Universal reference ( T&& ): lvalue args make T and ParamType lvalue references; rvalues follow case 1. By value: ignore reference, then ignore const / volatile (the param is a copy). Arrays and functions decay to pointers when passed by value, but T& deduces the real array type including size ( const char(&)[13] ). This enables a constexpr arraySize template. Why: auto is built on these rules, ...
Recent posts

C++ Smart Pointer Interview Questions

  C++ Smart Pointer Interview Questions ( unique_ptr , shared_ptr , weak_ptr ) Senior interviews on smart pointers go well beyond "what is unique_ptr ?". Interviewers want to see that you understand ownership design, control-block mechanics, thread safety, performance costs, and the classic bugs. This set of 22 questions progresses from fundamentals to implementation-level topics, each with an interview-ready answer, explanation, and example. Fundamentals 1. What problem do smart pointers solve, and how do the three types differ? Smart pointers encode ownership in the type system and use RAII to release the resource automatically, including when exceptions are thrown. They largely eliminate manual delete , leaks, and double-frees. Type Ownership Copyable? Typical cost unique_ptr Exclusive (one owner) No (move only) Same as a raw pointer (with the default deleter) shared_ptr Shared (reference counted) Yes Control block + atomic reference counting ...

Top 15 C++26 Features

  Top 15 C++26 Features C++26 is the first release since C++11 that changes what the language can do , not just how conveniently you write it. The ISO committee finished technical work on C++26 at its March 2026 meeting in London Croydon. The draft then moves through the ISO approval ballot and final editorial work toward publication. These are the 15 most important features, ordered by impact. The first three (reflection, contracts, std::execution ) are the headline features. Items 4 and 5 are the big safety wins. The rest are the language and library additions you are most likely to use or be asked about. A note on compiler support: implementations are still catching up, and some items below are only partially available. GCC 16 is reported to support most of the C++26 features, but check the cppreference C++26 compiler support table for the exact toolchain you ship on. The code below follows the final design, but small syntax details may differ from what your compiler accept...