前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >C++核心准则编译边学-F.15 优先使用简单、常规的方式传递参数

C++核心准则编译边学-F.15 优先使用简单、常规的方式传递参数

作者头像
面向对象思考
发布2020-03-25 15:21:03
2820
发布2020-03-25 15:21:03
举报

F.15: Prefer simple and conventional ways of passing information(优先使用简单、常规的方式传递参数)

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.

使用“特别和高明的”技术会让人感到诧异,减慢其他程序员的理解进程,同时诱发错误。如果你确实感到需要对通常技术进行优化,认真衡量并确定这真是一个改进之后,将其文档化或注释,因为这个改进可能并不是可移植的。

译者注:日常生活还是应该以萝卜白菜为主,海参鲍鱼是好,但不是什么人,任何时候都应该吃的。

The following tables summarize the advice in the following Guidelines, F.16-21.

下面的表格概括了准则F.16-21的内容。

Normal parameter passing:

通常的参数传递:

Advanced parameter passing:

高级的参数传递:

译者注:关于两个表格的内容,后续文章中会有详细说明,这里不再赘述。

Use the advanced techniques only after demonstrating need, and document that need in a comment.

在使用高级技术之前必须说明需求,而且在注释行中文档化该需求。

译者

英文原文来自下面链接:

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-11-10,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 面向对象思考 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • F.15: Prefer simple and conventional ways of passing information(优先使用简单、常规的方式传递参数)
    • Reason(原因)
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档