Skip to content

Commit

Permalink
fix windows max min macro problem
Browse files Browse the repository at this point in the history
  • Loading branch information
axojhf committed Feb 18, 2023
1 parent 28c1a83 commit 3836b2c
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion include/glaze/core/write_chars.hpp
Expand Up @@ -51,7 +51,7 @@ namespace glz::detail
// maximum length for a double should be 24 chars, we use 64 to be sufficient
if constexpr (detail::resizeable<B>) {
if (ix + 64 > b.size()) [[unlikely]] {
b.resize(std::max(b.size() * 2, ix + 64));
b.resize((std::max)(b.size() * 2, ix + 64));
}
}

Expand Down
4 changes: 2 additions & 2 deletions include/glaze/frozen/bits/pmh.hpp
Expand Up @@ -133,7 +133,7 @@ struct seed_or_index {
using value_type = uint64_t;

private:
static constexpr value_type MINUS_ONE = std::numeric_limits<value_type>::max();
static constexpr value_type MINUS_ONE = (std::numeric_limits<value_type>::max)();
static constexpr value_type HIGH_BIT = ~(MINUS_ONE >> 1);

value_type value_ = 0;
Expand Down Expand Up @@ -190,7 +190,7 @@ pmh_tables<M, Hash> constexpr make_pmh_tables(const carray<Item, N> &
carray<seed_or_index, M> G; // Default constructed to "index 0"

// H becomes the second hash table in the resulting pmh function
constexpr std::size_t UNUSED = std::numeric_limits<std::size_t>::max();
constexpr std::size_t UNUSED = (std::numeric_limits<std::size_t>::max)();
carray<std::size_t, M> H;
H.fill(UNUSED);

Expand Down
4 changes: 2 additions & 2 deletions include/glaze/frozen/random.hpp
Expand Up @@ -71,8 +71,8 @@ namespace glz::frozen
while (n--)
operator()();
}
static constexpr result_type min() { return increment == 0u ? 1u : 0u; }
static constexpr result_type max() { return modulus - 1u; }
static constexpr result_type min_value() { return increment == 0u ? 1u : 0u; }
static constexpr result_type max_value() { return modulus - 1u; }
friend constexpr bool operator==(linear_congruential_engine const &self,
linear_congruential_engine const &other) {
return self.state_ == other.state_;
Expand Down
2 changes: 1 addition & 1 deletion include/glaze/json/read.hpp
Expand Up @@ -908,7 +908,7 @@ namespace glz

struct key_stats_t
{
uint32_t min_length = std::numeric_limits<uint32_t>::max();
uint32_t min_length = (std::numeric_limits<uint32_t>::max)();
uint32_t max_length{};
uint32_t length_range{};
};
Expand Down
2 changes: 1 addition & 1 deletion include/glaze/json/study.hpp
Expand Up @@ -99,7 +99,7 @@ namespace glz
{
size_t deconst_index = i;
for (auto &param_set : param_sets) {
const auto this_size = std::max(param_set.elements.size(), size_t{1});
const auto this_size = (std::max)(param_set.elements.size(), size_t{1});
const auto this_index = deconst_index % this_size;
deconst_index /= this_size;
std::visit(
Expand Down
2 changes: 1 addition & 1 deletion include/glaze/json/write.hpp
Expand Up @@ -182,7 +182,7 @@ namespace glz
// we use 4 * n to handle potential escape characters and quoted bounds (excessive safety)
if constexpr (detail::resizeable<B>) {
if ((ix + 4 * n) >= b.size()) [[unlikely]] {
b.resize(std::max(b.size() * 2, ix + 4 * n));
b.resize((std::max)(b.size() * 2, ix + 4 * n));
}
}

Expand Down
12 changes: 6 additions & 6 deletions include/glaze/util/dump.hpp
Expand Up @@ -91,7 +91,7 @@ namespace glz::detail
static constexpr auto n = s.size();

if (ix + n > b.size()) [[unlikely]] {
b.resize(std::max(b.size() * 2, ix + n));
b.resize((std::max)(b.size() * 2, ix + n));
}

std::memcpy(b.data() + ix, s.data(), n);
Expand All @@ -111,7 +111,7 @@ namespace glz::detail
inline void dumpn(size_t n, vector_like auto& b, auto&& ix) noexcept
{
if (ix + n > b.size()) [[unlikely]] {
b.resize(std::max(b.size() * 2, ix + n));
b.resize((std::max)(b.size() * 2, ix + n));
}

std::fill_n(b.data() + ix, n, c);
Expand All @@ -124,7 +124,7 @@ namespace glz::detail
static constexpr auto n = s.size();

if (ix + n > b.size()) [[unlikely]] {
b.resize(std::max(b.size() * 2, ix + n));
b.resize((std::max)(b.size() * 2, ix + n));
}

std::memcpy(b.data() + ix, s.data(), n);
Expand All @@ -143,7 +143,7 @@ namespace glz::detail
inline void dump(const sv str, vector_like auto& b, auto&& ix) noexcept {
const auto n = str.size();
if (ix + n > b.size()) [[unlikely]] {
b.resize(std::max(b.size() * 2, ix + n));
b.resize((std::max)(b.size() * 2, ix + n));
}

std::memcpy(b.data() + ix, str.data(), n);
Expand Down Expand Up @@ -250,7 +250,7 @@ namespace glz::detail
{
const auto n = bytes.size();
if (ix + n > b.size()) [[unlikely]] {
b.resize(std::max(b.size() * 2, ix + n));
b.resize((std::max)(b.size() * 2, ix + n));
}

std::memcpy(b.data() + ix, bytes.data(), n);
Expand All @@ -261,7 +261,7 @@ namespace glz::detail
inline void dump(const std::array<uint8_t, N>& bytes, B&& b, auto&& ix) noexcept
{
if (ix + N > b.size()) [[unlikely]] {
b.resize(std::max(b.size() * 2, ix + N));
b.resize((std::max)(b.size() * 2, ix + N));
}

std::memcpy(b.data() + ix, bytes.data(), N);
Expand Down
6 changes: 3 additions & 3 deletions include/glaze/util/hash_map.hpp
Expand Up @@ -104,7 +104,7 @@ namespace glz
if (index == N) return seed;
}

return std::numeric_limits<HashType>::max();
return (std::numeric_limits<HashType>::max)();
}

inline bool sv_neq(const sv s0, const sv s1) noexcept { return s0 != s1; }
Expand Down Expand Up @@ -171,7 +171,7 @@ namespace glz
++i;
}
ht.seed = naive_perfect_hash<N, HashType>(keys);
if (ht.seed == std::numeric_limits<HashType>::max()) {
if (ht.seed == (std::numeric_limits<HashType>::max)()) {
throw std::runtime_error("Unable to find perfect hash.");
}

Expand Down Expand Up @@ -218,7 +218,7 @@ namespace glz

std::sort(hashes.begin(), hashes.end());

uint8_t min_diff = std::numeric_limits<uint8_t>::max();
uint8_t min_diff = (std::numeric_limits<uint8_t>::max)();
for (size_t i = 0; i < N - 1; ++i) {
if ((hashes[i + 1] - hashes[i]) < min_diff) {
min_diff = hashes[i + 1] - hashes[i];
Expand Down
6 changes: 3 additions & 3 deletions include/glaze/util/progress_bar.hpp
Expand Up @@ -21,8 +21,8 @@ namespace glz
std::string s{};

const size_t one = 1;
const auto one_or_total = std::max(total, one);
const auto one_or_completed = std::min(completed, one_or_total);
const auto one_or_total = (std::max)(total, one);
const auto one_or_completed = (std::min)(completed, one_or_total);
const auto progress = static_cast<double>(one_or_completed) / one_or_total;
const auto percentage = static_cast<size_t>(std::round(progress * 100));

Expand All @@ -44,7 +44,7 @@ namespace glz
}

const auto eta_s = static_cast<size_t>(
std::round(((one_or_total - one_or_completed) * time_taken) / std::max(one_or_completed, one)));
std::round(((one_or_total - one_or_completed) * time_taken) / (std::max)(one_or_completed, one)));
const auto minutes = eta_s / 60;
const auto seconds = eta_s - minutes * 60;
s += " " + std::to_string(std::lround(percentage)) + "%";
Expand Down
2 changes: 1 addition & 1 deletion include/glaze/util/strod.hpp
Expand Up @@ -478,7 +478,7 @@ namespace glz::detail
#undef expr_stop
/* read more digits in integral part */
digi_intg_more :
static constexpr uint64_t U64_MAX = std::numeric_limits<uint64_t>::max(); // todo
static constexpr uint64_t U64_MAX = (std::numeric_limits<uint64_t>::max)(); // todo
if ((num_tmp = *cur - zero) < 10) {
if (!digi_is_digit_or_fp(cur[1])) {
/* this number is an integer consisting of 20 digits */
Expand Down

0 comments on commit 3836b2c

Please sign in to comment.