Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

range-based iteration over linq expression without to_vector() #12

Open
PhilippC opened this issue Feb 18, 2016 · 1 comment
Open

range-based iteration over linq expression without to_vector() #12

PhilippC opened this issue Feb 18, 2016 · 1 comment

Comments

@PhilippC
Copy link
Contributor

maybe this is possible already, but I haven't found out how.

If I have a

auto my_elements = linq::from().where(...).select(..);

how can I iterate over those?

Currently I am doing

for (auto el: my_elements.to_vector())

but that seems inefficient. Is there a way to return an iterator pair from my_elements?

@timothy-shields
Copy link
Owner

Use the for_each function on interactive:

linq::from(people)
    .select([](Person& person){ return person.name; })
    .for_each([](std::string& name){ std::cout << name << std::endl; });

On Feb 18, 2016, at 4:03 AM, "PhilippC" [email protected] wrote:

maybe this is possible already, but I haven't found out how.

If I have a

auto my_elements = linq::from().where(...).select(..);

how can I iterate over those?

Currently I am doing

for (auto el: my_elements.to_vector())

but that seems inefficient. Is there a way to return an iterator pair from my_elements?


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants