Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix #define min/max problem from Windows.h #101

Merged
merged 1 commit into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/indicators/block_progress_bar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class BlockProgressBar {

size_t current() {
std::lock_guard<std::mutex> lock{mutex_};
return std::min(static_cast<size_t>(progress_),
return (std::min)(static_cast<size_t>(progress_),
size_t(get_value<details::ProgressBarOption::max_progress>()));
}

Expand Down Expand Up @@ -179,7 +179,7 @@ class BlockProgressBar {
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(now - start_time_point_);

if (get_value<details::ProgressBarOption::show_percentage>()) {
os << " " << std::min(static_cast<size_t>(progress_ / max_progress * 100.0), size_t(100))
os << " " << (std::min)(static_cast<size_t>(progress_ / max_progress * 100.0), size_t(100))
<< "%";
}

Expand Down
2 changes: 1 addition & 1 deletion include/indicators/details/stream_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class BlockProgressScaleWriter {
std::ostream &write(float progress) {
std::string fill_text{"█"};
std::vector<std::string> lead_characters{" ", "▏", "▎", "▍", "▌", "▋", "▊", "▉"};
auto value = std::min(1.0f, std::max(0.0f, progress / 100.0f));
auto value = (std::min)(1.0f, (std::max)(0.0f, progress / 100.0f));
auto whole_width = std::floor(value * bar_width);
auto remainder_width = fmod((value * bar_width), 1.0f);
auto part_width = std::floor(remainder_width * lead_characters.size());
Expand Down
4 changes: 2 additions & 2 deletions include/indicators/progress_bar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class ProgressBar {

size_t current() {
std::lock_guard<std::mutex> lock{mutex_};
return std::min(
return (std::min)(
progress_,
size_t(get_value<details::ProgressBarOption::max_progress>()));
}
Expand Down Expand Up @@ -231,7 +231,7 @@ class ProgressBar {

if (get_value<details::ProgressBarOption::show_percentage>()) {
os << " "
<< std::min(static_cast<size_t>(static_cast<float>(progress_) /
<< (std::min)(static_cast<size_t>(static_cast<float>(progress_) /
max_progress * 100),
size_t(100))
<< "%";
Expand Down
2 changes: 1 addition & 1 deletion include/indicators/progress_spinner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class ProgressSpinner {

size_t current() {
std::lock_guard<std::mutex> lock{mutex_};
return std::min(progress_, size_t(get_value<details::ProgressBarOption::max_progress>()));
return (std::min)(progress_, size_t(get_value<details::ProgressBarOption::max_progress>()));
}

bool is_completed() const { return get_value<details::ProgressBarOption::completed>(); }
Expand Down
14 changes: 7 additions & 7 deletions single_include/indicators/indicators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2900,7 +2900,7 @@ class BlockProgressScaleWriter {
std::ostream &write(float progress) {
std::string fill_text{"█"};
std::vector<std::string> lead_characters{" ", "▏", "▎", "▍", "▌", "▋", "▊", "▉"};
auto value = std::min(1.0f, std::max(0.0f, progress / 100.0f));
auto value = (std::min)(1.0f, (std::max)(0.0f, progress / 100.0f));
auto whole_width = std::floor(value * bar_width);
auto remainder_width = fmod((value * bar_width), 1.0f);
auto part_width = std::floor(remainder_width * lead_characters.size());
Expand Down Expand Up @@ -3128,7 +3128,7 @@ class BlockProgressScaleWriter {
std::ostream &write(float progress) {
std::string fill_text{"█"};
std::vector<std::string> lead_characters{" ", "▏", "▎", "▍", "▌", "▋", "▊", "▉"};
auto value = std::min(1.0f, std::max(0.0f, progress / 100.0f));
auto value = (std::min)(1.0f, (std::max)(0.0f, progress / 100.0f));
auto whole_width = std::floor(value * bar_width);
auto remainder_width = fmod((value * bar_width), 1.0f);
auto part_width = std::floor(remainder_width * lead_characters.size());
Expand Down Expand Up @@ -3445,7 +3445,7 @@ class ProgressBar {

size_t current() {
std::lock_guard<std::mutex> lock{mutex_};
return std::min(
return (std::min)(
progress_,
size_t(get_value<details::ProgressBarOption::max_progress>()));
}
Expand Down Expand Up @@ -3510,7 +3510,7 @@ class ProgressBar {

if (get_value<details::ProgressBarOption::show_percentage>()) {
os << " "
<< std::min(static_cast<size_t>(static_cast<float>(progress_) /
<< (std::min)(static_cast<size_t>(static_cast<float>(progress_) /
max_progress * 100),
size_t(100))
<< "%";
Expand Down Expand Up @@ -3762,7 +3762,7 @@ class BlockProgressBar {

size_t current() {
std::lock_guard<std::mutex> lock{mutex_};
return std::min(static_cast<size_t>(progress_),
return (std::min)(static_cast<size_t>(progress_),
size_t(get_value<details::ProgressBarOption::max_progress>()));
}

Expand Down Expand Up @@ -3819,7 +3819,7 @@ class BlockProgressBar {
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(now - start_time_point_);

if (get_value<details::ProgressBarOption::show_percentage>()) {
os << " " << std::min(static_cast<size_t>(progress_ / max_progress * 100.0), size_t(100))
os << " " << (std::min)(static_cast<size_t>(progress_ / max_progress * 100.0), size_t(100))
<< "%";
}

Expand Down Expand Up @@ -4544,7 +4544,7 @@ class ProgressSpinner {

size_t current() {
std::lock_guard<std::mutex> lock{mutex_};
return std::min(progress_, size_t(get_value<details::ProgressBarOption::max_progress>()));
return (std::min)(progress_, size_t(get_value<details::ProgressBarOption::max_progress>()));
}

bool is_completed() const { return get_value<details::ProgressBarOption::completed>(); }
Expand Down