C++核心準(zhǔn)則編譯邊學(xué)-F.15 優(yōu)先使用簡單、常規(guī)的方式傳遞參數(shù)

F.15: Prefer simple and conventional ways of passing information(優(yōu)先使用簡單、常規(guī)的方式傳遞參數(shù))
Reason(原因)
Using "unusual and clever" techniques causes surprises, slows understanding by other programmers, and encourages bugs. If you really feel the need for an optimization beyond the common techniques, measure to ensure that it really is an improvement, and document/comment because the improvement may not be portable.
使用“特別和高明的”技術(shù)會讓人感到詫異,減慢其他程序員的理解進(jìn)程,同時誘發(fā)錯誤。如果你確實(shí)感到需要對通常技術(shù)進(jìn)行優(yōu)化,認(rèn)真衡量并確定這真是一個改進(jìn)之后,將其文檔化或注釋,因?yàn)檫@個改進(jìn)可能并不是可移植的。
譯者注:日常生活還是應(yīng)該以蘿卜白菜為主,海參鮑魚是好,但不是什么人,任何時候都應(yīng)該吃的。
The following tables summarize the advice in the following Guidelines, F.16-21.
下面的表格概括了準(zhǔn)則F.16-21的內(nèi)容。
Normal parameter passing:
通常的參數(shù)傳遞:

Advanced parameter passing:
高級的參數(shù)傳遞:

譯者注:關(guān)于兩個表格的內(nèi)容,后續(xù)文章中會有詳細(xì)說明,這里不再贅述。
Use the advanced techniques only after demonstrating need, and document that need in a comment.
在使用高級技術(shù)之前必須說明需求,而且在注釋行中文檔化該需求。
譯者
英文原文來自下面鏈接:
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md
