Category cpp_nibble

#067 – Bounds-checked character access using string::at()

std::string offers two ways to read a character at a position: s[i] and s.at(i). They look interchangeable, and for a valid index they are. The difference shows up at exactly the moment you care most — when i is out of range. operator[] produces undefined behaviour; at() throws std::out_of_range. The choice…

#066 – Implementing custom deduction guides for CTAD

C++17’s class template argument deduction (CTAD) lets you write std::pair p{1, 2} instead of std::pair<int, int> p{1, 2} — the compiler figures out the template arguments from the constructor call. For most class templates this works automatically, because the compiler synthesises an implicit deduction guide from…