[cfe-dev] Don't help the compiler!
David Chisnall
David.Chisnall at cl.cam.ac.uk
Mon Jan 26 01:15:40 PST 2015
On 23 Jan 2015, at 16:32, Csaba Raduly <rcsaba at gmail.com> wrote:
>
> STL (Stephan T. Lavavej) in his talk at Going Native 2013, gave this
> example of an attempt to "help the compiler", which is at best
> superfluous:
>
> auto p = std::make_pair<int, double>(42, 3.1415);
>
> and recommended
>
> auto p = std::make_pair (42, 3.1415);
The latter form seems less readable. The fact that a floating point literal is a double unless suffixed with f is something that is rarely important for developers to remember, so this extra piece of information increases the cognitive burden when reading the code.
The goal of the former form is not to 'help the compiler', it is to help the poor sap who has to maintain this code in a couple of years.
David
More information about the cfe-dev
mailing list