In C#, I can create an iterator (or IEnumerable
in C# land) which takes another iterator and selects a member of the original type:
class ParentType
{
public MemberType member { get; private set; }
}
// And somewhere else
IEnumerable<MemberType> getMembers(IEnumerable<ParentType> parents)
{
for each (ParentType parent in parents)
yield return parent.member;
}
How would I do a similar operation in C++, where I want to basically take an iterator of a type, and return an iterator which iterates over a particular member?