I've run into a use case where I'd like to use a mapped_iterator to iterator the 1st (or 2nd) items in a sequence of std::pairs. Does select1st/select2nd exist somewhere within LLVM or is there some equivalent? If not, I'll add it. -Dave
On Jul 15, 2011, at 12:35 PM, David Greene wrote:> I've run into a use case where I'd like to use a mapped_iterator to > iterator the 1st (or 2nd) items in a sequence of std::pairs. Does > select1st/select2nd exist somewhere within LLVM or is there some > equivalent? If not, I'll add it.Is this making the resultant loop simpler? C++ without lambda's isn't very friendly to functors, what is the before/after effect of doing this? -Chris
I believe he's referring to this: http://www.sgi.com/tech/stl/select1st.html On Fri, Jul 15, 2011 at 1:29 PM, Chris Lattner <clattner at apple.com> wrote:> > On Jul 15, 2011, at 12:35 PM, David Greene wrote: > >> I've run into a use case where I'd like to use a mapped_iterator to >> iterator the 1st (or 2nd) items in a sequence of std::pairs. Does >> select1st/select2nd exist somewhere within LLVM or is there some >> equivalent? If not, I'll add it. > > Is this making the resultant loop simpler? C++ without lambda's isn't very friendly to functors, what is the before/after effect of doing this? > > -Chris > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Chris Lattner <clattner at apple.com> writes:> On Jul 15, 2011, at 12:35 PM, David Greene wrote: > >> I've run into a use case where I'd like to use a mapped_iterator to >> iterator the 1st (or 2nd) items in a sequence of std::pairs. Does >> select1st/select2nd exist somewhere within LLVM or is there some >> equivalent? If not, I'll add it. > > Is this making the resultant loop simpler? C++ without lambda's isn't > very friendly to functors, what is the before/after effect of doing > this?It's going to unify the DagInit constructors into one piece of code. The problem now is there are two constructors. One takes a vector of pairs and the other takes two vectors. They each make sense in their use contexts but it results in a lot of code duplication when moving DagInit to a uniqued pool implementation. I wanted to put the processing code in a third function which would be called with various types of iterators over those vectors. -Dave