When iterating over maps or using pairs, const correctness prevents accidental modifications. Use const auto& when you only read: for (const auto& [k, v] : myMap) { . } This documents intent and catches bugs at compile time.
For pairs returned from functions, returning by const reference avoids copies: const pair<int, int>& getPoint() { return cached; } Inside classes, mark methods const if they don't modify state: int getFirst() const { return p.first; } This lets you call the method on const objects.