KO
|
EN
gitlite — search
Search
#python
#java
#python3
#arduino
#golang
#machine-learning
#rust
#html
#flask
#javascript
#seismology
#nodejs
pbar
★ 20
Open GitHub ↗
⌛ Tiny header-only progress bar library for C++
Download README (.md)
Explore Similar Repositories
TensorRider_Self_Driving_Car
:
基于BP神经网络的自动驾驶模型车。包含收集数据、控制模型生成与在线/离线自动运行所需的程序。
programmer-dvorak-eu
:
A single layout. Both for prgramming, and for civil life.
textRewriting
:
中文文本改写
hugo-utilitybelt
:
A theme consisting of partials that can be added as a theme component for any Hugo site
Data-Analyst-Nanodegree
:
Code and Projects for Data Analyst Nanodegree.
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
pbar
?
Download (.md)
# Pbar A tiny header-only progress bar library for C++. The progress bar is itself an iterator, whose `operator++()` is overloaded to output a progress bar to `std::clog` on each call. <p align="center"> <img src="https://i.imgur.com/1nsWz9C.gif"> </p> ### Usage ~~~cpp #include <iostream> #include <vector> #include <unistd.h> #include "pbar.h" using namespace pbar; int main() { int us = 100000; std::vector<int> v = {1, 2, 3, 4, 5}; // Construct a ProgressBar for iterating over v, with a total width of 50 characters ProgressBar<std::vector<int>::iterator> pbar(v.begin(), v.end(), 50); for (auto i = pbar.begin(); i != pbar.end(); i++) { usleep(us); } // In C++17, the template argument may be omitted // The constructor allows changing the bar symbol (default '=') ProgressBar pbar2(v.begin(), v.end(), 50, '#'); std::cout << "\nRange based loops also work" << std::endl; for (auto& i: pbar2) { usleep(us); } } ~~~ ### Notes Currently, calling `ProgressBar::begin()` resets the internal counter to zero, so calling `begin()` on the progress bar object during iteration will reset the bar. This is not ideal, so for the moment you shouldn't call `begin()` on the ProgressBar when you need to access the first element, but instead call it on the actual container you're iterating over. ### Credits * [This](https://stackoverflow.com/a/14539953) StackOverflow answer, where I got part of the implementation from. * Toby Speight on codereview stackexchange, who helped signicantly improve the code quality.