是否有一种情况,通过引用比C中的pass-by-value更昂贵?如果是这样,那是什么情况呢?
解决方法
喜欢通过值复制(Point,complex)的原始类型(int,char,float,…)和POD结构.
这将比通过引用时所需的间接更有效.
The template class
call_traits<T>
encapsulates the “best” method to pass a parameter of some type T to or from a function,and consists of a collection of typedefs defined as in the table below. The purpose ofcall_traits
is to ensure that problems like “references to references” never occur,and that parameters are passed in the most efficient manner possible.