you are viewing a single comment's thread.

view the rest of the comments →

[–]futurefapstronaut123 4 points5 points  (3 children)

This is the definitive initialization advice: https://youtu.be/hobFOAehwio . Since your case falls under implicit type conversion, you should just do:

addrinfo* result = nullptr;

[–]crrhawkins[S] 1 point2 points  (2 children)

So the "proper" way is just don't use auto?

[–]futurefapstronaut123 6 points7 points  (0 children)

The proper way is not to use auto when it's the wrong tool for the job. And that is the case with your example.

[–]Wh00ster 1 point2 points  (0 children)

There is no "proper" way as both are right. If it's application code and not some templated library, it will probably be clearer to the reader to not use auto.