[cfe-dev] C++11 reverse iterators (was C++11 is here)

Chandler Carruth chandlerc at google.com
Tue Mar 4 17:49:28 PST 2014


On Mon, Mar 3, 2014 at 4:42 PM, Chris Lattner <sabre at nondot.org> wrote:

> Ok, can this be generalized into guidance we can put in the coding
> standards?


I mean, maybe. I'm not sure it comes up frequently enough to be worth space.

My off-the-cuff idea of how to say this in the guide would be:

"""
When providing getters and setters in APIs they should generally have value
semantics: the returned object from a getter should be immutable or a copy,
and arguments to the setter should be copied into the object. Naturally, if
the member is itself a pointer, this applies to the pointer and not the
pointee. If you are providing access to contained objects through some
transparent view like iterators, ranges, or adaptors these should have
reference semantics and be distinct from either a getter or a setter.
"""

But this isn't terribly satisfying to me as a rule. It's much easier to
talk in context about specific APIs than provide this level of guidance IMO.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140304/ab6dd1a3/attachment.html>


More information about the cfe-dev mailing list