Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Prevent min / max macro expansion on Windows #111

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion include/nanorange/algorithm/inplace_merge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ struct inplace_merge_fn {
++dist2;
}

const auto sz = nano::min(dist1, dist2);
const auto sz = (nano::min)(dist1, dist2);
auto buf = detail::temporary_vector<iter_value_t<I>>(sz);

if (buf.capacity() >= static_cast<std::size_t>(sz)) {
Expand Down
4 changes: 2 additions & 2 deletions include/nanorange/algorithm/sample.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct sample_fn {

auto unsampled_size = nano::distance(first, last);

for (n = nano::min(n, unsampled_size); n != 0; ++first) {
for (n = (nano::min)(n, unsampled_size); n != 0; ++first) {
if (D(g, param_t(0, --unsampled_size)) < n) {
*out++ = *first;
--n;
Expand Down Expand Up @@ -64,7 +64,7 @@ struct sample_fn {
}
}

return out + nano::min(n, k);
return out + (nano::min)(n, k);
}

template <typename I, typename S, typename O, typename Gen>
Expand Down
2 changes: 1 addition & 1 deletion include/nanorange/algorithm/stable_sort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ struct stable_sort_fn {
result, std::ref(comp), std::ref(proj), std::ref(proj)).out;
first += two_step;
}
step_size = nano::min(iter_difference_t<I>(last - first), step_size);
step_size = (nano::min)(iter_difference_t<I>(last - first), step_size);
nano::merge(
nano::make_move_iterator(first),
nano::make_move_iterator(first + step_size),
Expand Down
4 changes: 2 additions & 2 deletions include/nanorange/random.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ struct uniform_random_bit_generator_concept {

template <typename G>
auto requires_() -> decltype(
requires_expr<same_as<decltype(G::min()), invoke_result_t<G&>>>{},
requires_expr<same_as<decltype(G::max()), invoke_result_t<G&>>>{}
requires_expr<same_as<decltype((G::min)()), invoke_result_t<G&>>>{},
requires_expr<same_as<decltype((G::max)()), invoke_result_t<G&>>>{}
);
};

Expand Down
4 changes: 2 additions & 2 deletions include/nanorange/views/take.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ struct take_view : view_interface<take_view<V>> {
constexpr auto size()
{
auto n = ranges::size(base_);
return ranges::min(n, static_cast<decltype(n)>(count_));
return (ranges::min)(n, static_cast<decltype(n)>(count_));
}

template <typename VV = V, std::enable_if_t<sized_range<const VV>, int> = 0>
constexpr auto size() const
{
auto n = ranges::size(base_);
return ranges::min(n, static_cast<decltype(n)>(count_));
return (ranges::min)(n, static_cast<decltype(n)>(count_));
}
};

Expand Down
18 changes: 9 additions & 9 deletions single_include/nanorange.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ NANO_CONCEPT input_or_output_iterator =

template <typename S, typename I>
NANO_CONCEPT sentinel_for =
semiregular<S> && input_or_output_iterator<I> &&
semiregular<S> && input_or_output_iterator<I> &&
detail::weakly_equality_comparable_with<S, I>;

// [iterator.concept.sizedsentinel]
Expand Down Expand Up @@ -8796,7 +8796,7 @@ struct inplace_merge_fn {
++dist2;
}

const auto sz = nano::min(dist1, dist2);
const auto sz = (nano::min)(dist1, dist2);
auto buf = detail::temporary_vector<iter_value_t<I>>(sz);

if (buf.capacity() >= static_cast<std::size_t>(sz)) {
Expand Down Expand Up @@ -12630,8 +12630,8 @@ struct uniform_random_bit_generator_concept {

template <typename G>
auto requires_() -> decltype(
requires_expr<same_as<decltype(G::min()), invoke_result_t<G&>>>{},
requires_expr<same_as<decltype(G::max()), invoke_result_t<G&>>>{}
requires_expr<same_as<decltype((G::min)()), invoke_result_t<G&>>>{},
requires_expr<same_as<decltype((G::max)()), invoke_result_t<G&>>>{}
);
};

Expand Down Expand Up @@ -12666,7 +12666,7 @@ struct sample_fn {

auto unsampled_size = nano::distance(first, last);

for (n = nano::min(n, unsampled_size); n != 0; ++first) {
for (n = (nano::min)(n, unsampled_size); n != 0; ++first) {
if (D(g, param_t(0, --unsampled_size)) < n) {
*out++ = *first;
--n;
Expand Down Expand Up @@ -12696,7 +12696,7 @@ struct sample_fn {
}
}

return out + nano::min(n, k);
return out + (nano::min)(n, k);
}

template <typename I, typename S, typename O, typename Gen>
Expand Down Expand Up @@ -13839,7 +13839,7 @@ struct stable_sort_fn {
result, std::ref(comp), std::ref(proj), std::ref(proj)).out;
first += two_step;
}
step_size = nano::min(iter_difference_t<I>(last - first), step_size);
step_size = (nano::min)(iter_difference_t<I>(last - first), step_size);
nano::merge(
nano::make_move_iterator(first),
nano::make_move_iterator(first + step_size),
Expand Down Expand Up @@ -18606,14 +18606,14 @@ struct take_view : view_interface<take_view<V>> {
constexpr auto size()
{
auto n = ranges::size(base_);
return ranges::min(n, static_cast<decltype(n)>(count_));
return (ranges::min)(n, static_cast<decltype(n)>(count_));
}

template <typename VV = V, std::enable_if_t<sized_range<const VV>, int> = 0>
constexpr auto size() const
{
auto n = ranges::size(base_);
return ranges::min(n, static_cast<decltype(n)>(count_));
return (ranges::min)(n, static_cast<decltype(n)>(count_));
}
};

Expand Down