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 for loops #1

Open
paulpach opened this issue Jun 15, 2017 · 0 comments
Open

range based for loops #1

paulpach opened this issue Jun 15, 2017 · 0 comments

Comments

@paulpach
Copy link

paulpach commented Jun 15, 2017

I figured that rather than add to my post in quora, I could just add items as issues as I find them.
Feel free to delete the issue if you want me to stop.

Consider using range based for loops, for example, instead of this:

    for (int i = 0; i < thread_num; i++) {
        threads[i]->_join();
    }

you could do:

    for (auto thread: threads) {
        thread->join();
    }

They are part of C++ 11 and make the code a lot more readable. In some cases it can make the code faster, for example if you are using a linked list.

@paulpach paulpach changed the title for loops range based for loops Jun 15, 2017
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

1 participant