This is an archive of the discontinued LLVM Phabricator instance.

Mark the operations of __wrap_iter as constexpr
Needs ReviewPublic

Authored by mclow.lists on Jun 15 2017, 6:53 AM.

Details

Reviewers
EricWF
Summary

__wrap_iter is an internal libc++ class used to, well, wrap other iterators (such as pointers) when we need or want an object type.

Mark the operations on __wrap_iter as constexpr, so that they can be used in a constexpr context if the underlying iterator can be used in such a context.

I've had this kicking around my machine for a while, and it hasn't caused any problems.
It probably needs a few tests before committing, though.

Diff Detail

Event Timeline

mclow.lists created this revision.Jun 15 2017, 6:53 AM
EricWF edited edge metadata.Jun 15 2017, 5:00 PM

Could you re-upload this with a updated diff against trunk, and one with more context.

A large portion of this patch is UB. Any function that unconditionally calls __get_db() can never be a valid constant expression, hence UB.

Is there a smaller set of operations or __wrap_iter that *must* be made constexpr? Or do they all need to be?

include/algorithm
1765

These definitions should probably be moved to <iterator> where they are declared. I'm not sure why they lived in <algorithm> to begin with.

include/iterator
1202

These forward declarations seem unnecessary since they're also forward declared as friend functions inside __wrap_iter