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: N4173
Date: 2014-10-11
Operator Dot
by Bjarne Stroustrup and Gabriel Dos Reis
Excerpt:
This is a proposal to allow user-defined operator dot (
operator.()
) so that we can provide “smart references” similar to the way we provide “smart pointers.” The gist of the proposal is that if anoperator.()
is defined for a classRef
then by default every operation on aRef
object is forwarded to the result ofoperator.()
. However, an operation explicitly declared as a member ofRef
is applied to theRef
object without forwarding. A programmer can prevent a pointer to a referred-to object from “leaking” into the larger program by declaringoperator.()
private.
Add a Comment
Comments are closed.