DEV Community

Discussion on: C++ Productivity Hacks

Collapse
 
sandordargo profile image
Sandor Dargo

In my opinion it would be worth explaining why something is considered a productivity trick at what it does. Plus, prepend std:: in case it's needed, because your readers might not know that std::accumulate is part of the <numeric> header.

A few comments without wanting to be complete here.

  1. In production environment never ever use <bits/stdc++.h>. It will blow the size of your software as it includes whatever, plus it's not portable between different compilers.

  2. No. In 2021 you barely need macros. Start with this.

6.-8. In C++ there is no built-in __builtin_popcount nor __gcd. Some compilers might or might not provide them. But at least std::gcd is provided by the the standard library in <numeric> header.

+1) Productivity trick. Understand what you use and why you use it, that's the only thing that will boost your productivity in the long run.