On 3 March 2014 12:32, Pete Cooper <peter_cooper at apple.com> wrote:> Would those work with a foreach construct? Perhaps I forgot to mention that was what I'm trying to work out here. > > In example 3 I was wondering if we could define a method reverse(). We could use sfinae to wrap that around rbegin/rend if people like that style?Sorry, I was too terse... ;) If MF is a reverse_iterator, it'd just work, no? But to get the reverse iterator, I think reverse() would be the best general pattern, since you can adapt it to each container needs. cheers, --renato
On Mar 2, 2014, at 8:53 PM, Renato Golin <renato.golin at linaro.org> wrote:> On 3 March 2014 12:32, Pete Cooper <peter_cooper at apple.com> wrote: >> Would those work with a foreach construct? Perhaps I forgot to mention that was what I'm trying to work out here. >> >> In example 3 I was wondering if we could define a method reverse(). We could use sfinae to wrap that around rbegin/rend if people like that style? > > Sorry, I was too terse... ;) > > If MF is a reverse_iterator, it'd just work, no? But to get the > reverse iterator, I think reverse() would be the best general pattern, > since you can adapt it to each container needs.I'm not aware of the prior art or standards are here, but I think that a global reverse() adapter is the way to go. Likewise, we should have a standard "enumerate()" adaptor like python. -Chris
Saleem Abdulrasool
2014-Mar-03 06:13 UTC
[LLVMdev] [cfe-dev] C++11 reverse iterators (was C++11 is here)
On Sun, Mar 2, 2014 at 9:26 PM, Chris Lattner <sabre at nondot.org> wrote:> > On Mar 2, 2014, at 8:53 PM, Renato Golin <renato.golin at linaro.org> wrote: > > > On 3 March 2014 12:32, Pete Cooper <peter_cooper at apple.com> wrote: > >> Would those work with a foreach construct? Perhaps I forgot to mention > that was what I'm trying to work out here. > >> > >> In example 3 I was wondering if we could define a method reverse(). We > could use sfinae to wrap that around rbegin/rend if people like that style? > > > > Sorry, I was too terse... ;) > > > > If MF is a reverse_iterator, it'd just work, no? But to get the > > reverse iterator, I think reverse() would be the best general pattern, > > since you can adapt it to each container needs. > > I'm not aware of the prior art or standards are here, but I think that a > global reverse() adapter is the way to go. Likewise, we should have a > standard "enumerate()" adaptor like python.I definitely prefer the global adaptor pattern. As for prior art, I had played with it a bit, and came up with https://gist.github.com/compnerd/5694186 a while back.> -Chris > _______________________________________________ > cfe-dev mailing list > cfe-dev at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev >-- Saleem Abdulrasool compnerd (at) compnerd (dot) org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140302/4d41ec38/attachment.html>
Sean Silva
2014-Mar-04 22:51 UTC
[LLVMdev] [cfe-dev] C++11 reverse iterators (was C++11 is here)
On Mon, Mar 3, 2014 at 12:26 AM, Chris Lattner <sabre at nondot.org> wrote:> > On Mar 2, 2014, at 8:53 PM, Renato Golin <renato.golin at linaro.org> wrote: > > > On 3 March 2014 12:32, Pete Cooper <peter_cooper at apple.com> wrote: > >> Would those work with a foreach construct? Perhaps I forgot to mention > that was what I'm trying to work out here. > >> > >> In example 3 I was wondering if we could define a method reverse(). We > could use sfinae to wrap that around rbegin/rend if people like that style? > > > > Sorry, I was too terse... ;) > > > > If MF is a reverse_iterator, it'd just work, no? But to get the > > reverse iterator, I think reverse() would be the best general pattern, > > since you can adapt it to each container needs. > > I'm not aware of the prior art or standards are here, but I think that a > global reverse() adapter is the way to go. Likewise, we should have a > standard "enumerate()" adaptor like python. >`enumerate` is going to be so much more annoying to use without tuple unpacking in the `for` syntax :( -- Sean Silva> > -Chris > _______________________________________________ > cfe-dev mailing list > cfe-dev at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140304/426aa83f/attachment.html>
Possibly Parallel Threads
- [LLVMdev] C++11 reverse iterators (was C++11 is here)
- [LLVMdev] [cfe-dev] C++11 reverse iterators (was C++11 is here)
- [LLVMdev] C++11 reverse iterators (was C++11 is here)
- [LLVMdev] Why the fault?
- [LLVMdev] [cfe-dev] C++11 reverse iterators (was C++11 is here)