Progress class

A thread-safe helper object to display and update a progress bar in the terminal.

Example usage:

{
    Progress p1("Solving", 10);
    for (int i = 0; i < 10; ++i, ++p1)
    {
        // do something
    }
} // end progress p1

Constructors, destructors, conversion operators

Progress(const std::string& title, int64_t total_steps = 0)
Create a progress bar with a title and total_steps number of steps.

Public functions

void step(int64_t steps = 1)
increment the progress by steps.
void set_done()
mark the progress as complete
auto progress() const -> int
the current progress
auto operator++() -> Progress&
increment the progress by 1 step
auto operator+=(int64_t steps) -> Progress&
increment the progress by steps.

Function documentation

Progress::Progress(const std::string& title, int64_t total_steps = 0)

Create a progress bar with a title and total_steps number of steps.

Parameters
title A descriptive title for the task being performed.
total_steps When this is positive, it indicates the number of steps for the calculation. When it is non-positive, an indeterminate progress bar is created instead (for a task with an unknown number of steps), and total_steps is used as the period, in milliseconds, of the progress bar's spinning animation. If 0 is specified, a default number of milliseconds is used.

void Progress::step(int64_t steps = 1)

increment the progress by steps.

Progress& Progress::operator+=(int64_t steps)

increment the progress by steps.