Skip to content

Commit

Permalink
Merge pull request #101 from Chuvi-w/Fix_Windows_h_min_max
Browse files Browse the repository at this point in the history
Fix #define min/max problem from Windows.h
  • Loading branch information
p-ranav authored Jul 12, 2021
2 parents e34840a + 28a8128 commit cdcff01
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
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

0 comments on commit cdcff01

Please sign in to comment.