🚨 fixed some clang-tidy warnings

This commit is contained in:
Niels Lohmann 2018-10-07 18:39:18 +02:00
parent fa722d5ac3
commit 858e75c4df
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
29 changed files with 214 additions and 204 deletions

View file

@ -299,7 +299,7 @@ void from_json(const BasicJsonType& j, std::pair<A1, A2>& p)
}
template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_sequence<Idx...>)
void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_sequence<Idx...> /*unused*/)
{
t = std::make_tuple(j.at(Idx).template get<typename std::tuple_element<Idx, Tuple>::type>()...);
}
@ -358,7 +358,7 @@ struct from_json_fn
return from_json(j, val);
}
};
}
} // namespace detail
/// namespace to hold default `from_json` function
/// to see why this is required:
@ -366,5 +366,5 @@ struct from_json_fn
namespace
{
constexpr const auto& from_json = detail::static_const<detail::from_json_fn>::value;
}
}
} // namespace
} // namespace nlohmann

View file

@ -47,10 +47,9 @@ struct diyfp // f * 2^e
{
static constexpr int kPrecision = 64; // = q
uint64_t f;
int e;
uint64_t f = 0;
int e = 0;
constexpr diyfp() noexcept : f(0), e(0) {}
constexpr diyfp(uint64_t f_, int e_) noexcept : f(f_), e(e_) {}
/*!
@ -62,7 +61,7 @@ struct diyfp // f * 2^e
assert(x.e == y.e);
assert(x.f >= y.f);
return diyfp(x.f - y.f, x.e);
return {x.f - y.f, x.e};
}
/*!
@ -127,7 +126,7 @@ struct diyfp // f * 2^e
const uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32);
return diyfp(h, x.e + y.e + 64);
return {h, x.e + y.e + 64};
}
/*!
@ -158,7 +157,7 @@ struct diyfp // f * 2^e
assert(delta >= 0);
assert(((x.f << delta) >> delta) == x.f);
return diyfp(x.f << delta, target_exponent);
return {x.f << delta, target_exponent};
}
};
@ -461,7 +460,7 @@ inline cached_power get_cached_power_for_binary_exponent(int e)
assert(e >= -1500);
assert(e <= 1500);
const int f = kAlpha - e - 1;
const int k = (f * 78913) / (1 << 18) + (f > 0);
const int k = (f * 78913) / (1 << 18) + static_cast<int>(f > 0);
const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
assert(index >= 0);
@ -609,7 +608,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
const diyfp one(uint64_t{1} << -M_plus.e, M_plus.e);
uint32_t p1 = static_cast<uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
auto p1 = static_cast<uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e
// 1)
@ -928,7 +927,7 @@ inline char* append_exponent(char* buf, int e)
*buf++ = '+';
}
uint32_t k = static_cast<uint32_t>(e);
auto k = static_cast<uint32_t>(e);
if (k < 10)
{
// Always print at least two digits in the exponent.
@ -1046,7 +1045,7 @@ format. Returns an iterator pointing past-the-end of the decimal representation.
@note The result is NOT null-terminated.
*/
template <typename FloatType>
char* to_chars(char* first, char* last, FloatType value)
char* to_chars(char* first, const char* last, FloatType value)
{
static_cast<void>(last); // maybe unused - fix warning
assert(std::isfinite(value));

View file

@ -312,7 +312,7 @@ void to_json(BasicJsonType& j, const T& b)
}
template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...>)
void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...> /*unused*/)
{
j = {std::get<Idx>(t)...};
}
@ -332,11 +332,11 @@ struct to_json_fn
return to_json(j, std::forward<T>(val));
}
};
}
} // namespace detail
/// namespace to hold default `to_json` function
namespace
{
constexpr const auto& to_json = detail::static_const<detail::to_json_fn>::value;
}
}
} // namespace
} // namespace nlohmann