Skip to content

Instantly share code, notes, and snippets.

@geektoni
Last active June 2, 2017 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geektoni/9f792c007a0c8dc801b2937337bea926 to your computer and use it in GitHub Desktop.
Save geektoni/9f792c007a0c8dc801b2937337bea926 to your computer and use it in GitHub Desktop.
// General version
// Works with multi threaded environment and imposes no constraints
// to the for() loop. This means that can be used inside a #pragma
// without problems.
pr = progress(range(0,10), io, ASCII)
for (int i=0; i<10; i++)
{
/* Do stuff */
pr.print_progress()
}
pr.complete();
// Compact version
// The current one, exploits the range-based loop
for (auto it : progress(range(0, 10), io, ASCII))
{
/* Do stuff */
}
// Compact version + condition
for (auto it : progress(range(0, 10), io, ASCII, [&]() {condition}))
{
/* Do stuff */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment