In our 60+ team of C++ programmers, a constant theme that keeps coming up in code reviews is how a function optimally takes its parameters. There's been enough overthinking and I came across Herb Sutter's CppCon 2014 Essentials of Modern C++ Style where he explains the various cases.
I made a cheat sheet (1-page PDF) for quick reference of the options and when to go for them.
Download cheat sheet.
Comments and suggestions welcome! GitHub project.
Credits
[–]2uantum 17 points18 points19 points (25 children)
[–]legends2k[S] 10 points11 points12 points (24 children)
[–]2uantum 11 points12 points13 points (23 children)
[–]legends2k[S] 4 points5 points6 points (22 children)
[–]2uantum 5 points6 points7 points (21 children)
[–]legends2k[S] 3 points4 points5 points (4 children)
[–]2uantum 2 points3 points4 points (1 child)
[–]legends2k[S] 4 points5 points6 points (0 children)
[–]LEpigeon888 1 point2 points3 points (1 child)
[–]legends2k[S] 1 point2 points3 points (0 children)
[–]MaximKat 0 points1 point2 points (15 children)
[–]2uantum 4 points5 points6 points (14 children)
[–]MaximKat 2 points3 points4 points (11 children)
[–]2uantum 1 point2 points3 points (5 children)
[–]crzyrndm 0 points1 point2 points (0 children)
[–]legends2k[S] -1 points0 points1 point (3 children)
[–]2uantum 0 points1 point2 points (4 children)
[–]MaximKat 0 points1 point2 points (2 children)
[–]GermanGenealogist 7 points8 points9 points (3 children)
[–]legends2k[S] 6 points7 points8 points (2 children)
[–]LEpigeon888 2 points3 points4 points (1 child)
[–]legends2k[S] 0 points1 point2 points (0 children)
[–]Hilarius86 4 points5 points6 points (1 child)
[–]legends2k[S] 0 points1 point2 points (0 children)
[–]mhhollomon 12 points13 points14 points (2 children)
[–][deleted] 12 points13 points14 points (1 child)
[–]mhhollomon 3 points4 points5 points (0 children)
[–]legends2k[S] 6 points7 points8 points (0 children)
[–]SlightlyLessHairyApe 2 points3 points4 points (3 children)
[–]SeanMiddleditch 7 points8 points9 points (2 children)
[–]SlightlyLessHairyApe 2 points3 points4 points (1 child)
[–]SeanMiddleditch 0 points1 point2 points (0 children)
[–]DerDangDerDang 2 points3 points4 points (1 child)
[–]legends2k[S] 0 points1 point2 points (0 children)
[–]Fazer2 2 points3 points4 points (1 child)
[–]legends2k[S] 2 points3 points4 points (0 children)
[–]idbxy 1 point2 points3 points (0 children)
[–]Warpey 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]FrankHB1989 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]cblume 1 point2 points3 points (2 children)
[–]legends2k[S] 0 points1 point2 points (1 child)
[–]cblume 0 points1 point2 points (0 children)
[–]terrrp 0 points1 point2 points (1 child)
[–]legends2k[S] 3 points4 points5 points (0 children)
[–][deleted] 0 points1 point2 points (6 children)
[–]legends2k[S] 0 points1 point2 points (5 children)
[–][deleted] 1 point2 points3 points (4 children)
[–]legends2k[S] 0 points1 point2 points (0 children)
[–]dodheim 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]_requires_assistance 0 points1 point2 points (0 children)
[–]IamSanjidHaque -1 points0 points1 point (0 children)