diff --git a/SoftwareGuide/Latex/Appendices/CodingStyleGuide.tex b/SoftwareGuide/Latex/Appendices/CodingStyleGuide.tex index 5b87bb88..61fc7a05 100644 --- a/SoftwareGuide/Latex/Appendices/CodingStyleGuide.tex +++ b/SoftwareGuide/Latex/Appendices/CodingStyleGuide.tex @@ -2985,6 +2985,47 @@ \section{Increment/decrement Operators} \normalsize +\section{Trailing Return Types} +\label{sec:TrailingReturnTypes} + +Whenever choosing between a trailing return type (as introduced with C++11) and +the old form of having the return type before the function name (as was already +supported by C++98), prefer the form that is the shortest, and the simplest. + +In the following example, the old form is preferred over a trailing return type: +\small +\begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} +// Preferred: +template +bool +AlmostEquals(T1 x1, T2 x2) + +// Rather than: +template +auto +AlmostEquals(T1 x1, T2 x2) -> bool +\end{minted} +\normalsize + +In the following example, a trailing return type is preferred over the old form: + +\small +\begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} + +// Preferred: +template +auto +FixedArray::Size() const -> SizeType + +// Rather than: +template +typename FixedArray::SizeType +FixedArray::Size() const + +\end{minted} +\normalsize + + \section{Empty Arguments in Methods} \label{sec:EmptyArgumentInMethods}