New paper: N3538, Pass by Const Reference or Value -- Lawrence Crowl

A new WG21 paper is available. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.

Document number: N3538

Date: 2013-03-06

Pass by Const Reference or Value

by Lawrence Crowl

Excerpt:

Efficiency and expressiveness are hallmarks of C++, but sometimes those hallmarks conflict in ways that force programmers to compromise on one or the other. The progammer's choice of passing a given argument by const reference or by value is one of those compromises. That compromise has become more of a problem with modern calling conventions.

In this paper, we describe the problem, discuss possible approaches to reduce the problem, and explore a solution that introduces a new language feature...

Add a Comment

Comments are closed.

Comments (2)

1 0

Mateusz Loskot said on Mar 8, 2013 04:47 PM:

I have a question regarding the title of this paper.
From the C++ standard, I have learned that, in regard to objects, we "pass by reference" or we "pass by reference to const", but we don't "pass [const] reference".
Is my understanding of these standard notions correct?
If it is correct, why the paper title does not read "pass by reference to const or value"?
0 0

NoSenseEtAl said on Mar 11, 2013 05:35 AM:

Code examples please.
"Is this a ref or value" is already a readability problem. Without some code examples Ill guestimate this will only make things worse.
I wish standard would allow compilers to optimize const T to const T& for fat types and problem solved. TBH IDK if it is legal in C++11, but I guess it isnt since you cant prove copy ctors are side-effect free.