Skip to content

iterator proxy pair ought to decay to value semantics on demand #31

Open
@ned14

Description

Lots of generic STL code would always do:

for(auto &i : container)

This prevents the value copy of items being iterated. You have proxy pair in place to prevent this occurring for:

for(auto i : container)

Firstly, any compiler which is not MSVC will elide that copy under optimisation if i never escapes or is modified. So your proxy optimisation probably doesn't actually save much, except on MSVC.

Meanwhile, the lack of value sematics for the second for loop causes much generic code to break. If the code asked for a copy, it expects an as-if copy. If you wish to retain your proxy, you ought to have it implicitly convert to a value type upon demand in order to retain expected semantics.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

featureNew feature or enhancement request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions