Skip to content

Commit 79c7f8a

Browse files
committed
Apply clang-tidy
1 parent 20e0d6d commit 79c7f8a

File tree

7 files changed

+26
-25
lines changed

7 files changed

+26
-25
lines changed

include/fmt/args.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ FMT_EXPORT template <typename Context> class dynamic_format_arg_store {
212212
}
213213

214214
/// Returns the number of elements in the store.
215-
size_t size() const noexcept { return data_.size(); }
215+
auto size() const noexcept -> size_t { return data_.size(); }
216216
};
217217

218218
FMT_END_NAMESPACE

include/fmt/base.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,10 @@ enum { use_utf8 = !FMT_WIN32 || is_utf8_enabled };
458458
static_assert(!FMT_UNICODE || use_utf8,
459459
"Unicode support requires compiling with /utf-8");
460460

461-
template <typename T> constexpr const char* narrow(const T*) { return nullptr; }
462-
constexpr FMT_ALWAYS_INLINE const char* narrow(const char* s) { return s; }
461+
template <typename T> constexpr auto narrow(T*) -> char* { return nullptr; }
462+
constexpr FMT_ALWAYS_INLINE auto narrow(const char* s) -> const char* {
463+
return s;
464+
}
463465

464466
template <typename Char>
465467
FMT_CONSTEXPR auto compare(const Char* s1, const Char* s2, size_t n) -> int {
@@ -762,7 +764,7 @@ class basic_specs {
762764
(static_cast<unsigned>(p) << precision_shift);
763765
}
764766

765-
constexpr bool dynamic() const {
767+
constexpr auto dynamic() const -> bool {
766768
return (data_ & (width_mask | precision_mask)) != 0;
767769
}
768770

@@ -2369,8 +2371,8 @@ struct named_arg_store {
23692371
}
23702372

23712373
named_arg_store(const named_arg_store& rhs) = delete;
2372-
named_arg_store& operator=(const named_arg_store& rhs) = delete;
2373-
named_arg_store& operator=(named_arg_store&& rhs) = delete;
2374+
auto operator=(const named_arg_store& rhs) -> named_arg_store& = delete;
2375+
auto operator=(named_arg_store&& rhs) -> named_arg_store& = delete;
23742376
operator const arg_t<Context, NUM_ARGS>*() const { return args + 1; }
23752377
};
23762378

include/fmt/chrono.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,16 +1000,16 @@ template <typename T>
10001000
struct has_tm_zone<T, void_t<decltype(T::tm_zone)>> : std::true_type {};
10011001

10021002
template <typename T, FMT_ENABLE_IF(has_tm_zone<T>::value)>
1003-
bool set_tm_zone(T& time, char* tz) {
1003+
auto set_tm_zone(T& time, char* tz) -> bool {
10041004
time.tm_zone = tz;
10051005
return true;
10061006
}
10071007
template <typename T, FMT_ENABLE_IF(!has_tm_zone<T>::value)>
1008-
bool set_tm_zone(T&, char*) {
1008+
auto set_tm_zone(T&, char*) -> bool {
10091009
return false;
10101010
}
10111011

1012-
inline char* utc() {
1012+
inline auto utc() -> char* {
10131013
static char tz[] = "UTC";
10141014
return tz;
10151015
}

include/fmt/compile.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct is_compiled_string : std::is_base_of<compiled_string, S> {};
4343
* Converts a string literal into a format string that will be parsed at
4444
* compile time and converted into efficient formatting code. Requires support
4545
* for class types in constant template parameters (a C++20 feature).
46-
*
46+
*
4747
* **Example**:
4848
*
4949
* // Converts 42 into std::string using the most efficient method and no
@@ -71,8 +71,8 @@ template <typename... T> struct type_list {};
7171

7272
// Returns a reference to the argument at index N from [first, rest...].
7373
template <int N, typename T, typename... Args>
74-
constexpr const auto& get([[maybe_unused]] const T& first,
75-
[[maybe_unused]] const Args&... rest) {
74+
constexpr auto get([[maybe_unused]] const T& first,
75+
[[maybe_unused]] const Args&... rest) -> const auto& {
7676
static_assert(N < 1 + sizeof...(Args), "index is out of bounds");
7777
if constexpr (N == 0)
7878
return first;

include/fmt/format-inl.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ auto is_left_endpoint_integer_shorter_interval(int exponent) noexcept -> bool {
11621162
}
11631163

11641164
// Remove trailing zeros from n and return the number of zeros removed (float).
1165-
FMT_INLINE int remove_trailing_zeros(uint32_t& n, int s = 0) noexcept {
1165+
FMT_INLINE auto remove_trailing_zeros(uint32_t& n, int s = 0) noexcept -> int {
11661166
FMT_ASSERT(n != 0, "");
11671167
// Modular inverse of 5 (mod 2^32): (mod_inv_5 * 5) mod 2^32 = 1.
11681168
constexpr uint32_t mod_inv_5 = 0xcccccccd;
@@ -1183,7 +1183,7 @@ FMT_INLINE int remove_trailing_zeros(uint32_t& n, int s = 0) noexcept {
11831183
}
11841184

11851185
// Removes trailing zeros and returns the number of zeros removed (double).
1186-
FMT_INLINE int remove_trailing_zeros(uint64_t& n) noexcept {
1186+
FMT_INLINE auto remove_trailing_zeros(uint64_t& n) noexcept -> int {
11871187
FMT_ASSERT(n != 0, "");
11881188

11891189
// Is n is divisible by 10^8?
@@ -1219,7 +1219,7 @@ FMT_INLINE int remove_trailing_zeros(uint64_t& n) noexcept {
12191219

12201220
// The main algorithm for shorter interval case
12211221
template <typename T>
1222-
FMT_INLINE decimal_fp<T> shorter_interval_case(int exponent) noexcept {
1222+
FMT_INLINE auto shorter_interval_case(int exponent) noexcept -> decimal_fp<T> {
12231223
decimal_fp<T> ret_value;
12241224
// Compute k and beta
12251225
const int minus_k = floor_log10_pow2_minus_log10_4_over_3(exponent);
@@ -1555,7 +1555,7 @@ template <typename F> class glibc_file : public file_base<F> {
15551555

15561556
void advance_write_buffer(size_t size) { this->file_->_IO_write_ptr += size; }
15571557

1558-
bool needs_flush() const {
1558+
auto needs_flush() const -> bool {
15591559
if ((this->file_->_flags & line_buffered) == 0) return false;
15601560
char* end = this->file_->_IO_write_end;
15611561
auto size = max_of<ptrdiff_t>(this->file_->_IO_write_ptr - end, 0);
@@ -1604,7 +1604,7 @@ template <typename F> class apple_file : public file_base<F> {
16041604
this->file_->_w -= size;
16051605
}
16061606

1607-
bool needs_flush() const {
1607+
auto needs_flush() const -> bool {
16081608
if ((this->file_->_flags & line_buffered) == 0) return false;
16091609
return memchr(this->file_->_p + this->file_->_w, '\n',
16101610
to_unsigned(-this->file_->_w));

include/fmt/format.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ using is_double_double = bool_constant<std::numeric_limits<T>::digits == 106>;
736736
template <typename T> struct allocator : private std::decay<void> {
737737
using value_type = T;
738738

739-
T* allocate(size_t n) {
739+
auto allocate(size_t n) -> T* {
740740
FMT_ASSERT(n <= max_value<size_t>() / sizeof(T), "");
741741
T* p = static_cast<T*>(std::malloc(n * sizeof(T)));
742742
if (!p) FMT_THROW(std::bad_alloc());
@@ -940,7 +940,7 @@ class string_buffer {
940940
inline string_buffer() : buf_(str_) {}
941941

942942
inline operator writer() { return buf_; }
943-
inline std::string& str() { return str_; }
943+
inline auto str() -> std::string& { return str_; }
944944
};
945945

946946
template <typename T, size_t SIZE, typename Allocator>
@@ -2622,7 +2622,7 @@ FMT_CONSTEXPR auto isfinite(T value) -> bool {
26222622
}
26232623

26242624
template <typename T, FMT_ENABLE_IF(is_floating_point<T>::value)>
2625-
FMT_INLINE FMT_CONSTEXPR bool signbit(T value) {
2625+
FMT_INLINE FMT_CONSTEXPR auto signbit(T value) -> bool {
26262626
if (is_constant_evaluated()) {
26272627
#ifdef __cpp_if_constexpr
26282628
if constexpr (std::numeric_limits<double>::is_iec559) {
@@ -3698,9 +3698,9 @@ FMT_CONSTEXPR auto get_arg(Context& ctx, ID id) -> basic_format_arg<Context> {
36983698
}
36993699

37003700
template <typename Context>
3701-
FMT_CONSTEXPR int get_dynamic_spec(
3701+
FMT_CONSTEXPR auto get_dynamic_spec(
37023702
arg_id_kind kind, const arg_ref<typename Context::char_type>& ref,
3703-
Context& ctx) {
3703+
Context& ctx) -> int {
37043704
FMT_ASSERT(kind != arg_id_kind::none, "");
37053705
auto arg =
37063706
kind == arg_id_kind::index ? ctx.arg(ref.index) : ctx.arg(ref.name);

include/fmt/std.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,8 @@ struct is_variant_like_<std::variant<Types...>> : std::true_type {};
129129

130130
template <typename Variant, typename Char> class is_variant_formattable {
131131
template <size_t... Is>
132-
static std::conjunction<
133-
is_formattable<std::variant_alternative_t<Is, Variant>, Char>...>
134-
check(std::index_sequence<Is...>);
132+
static auto check(std::index_sequence<Is...>) -> std::conjunction<
133+
is_formattable<std::variant_alternative_t<Is, Variant>, Char>...>;
135134

136135
public:
137136
static constexpr bool value = decltype(check(

0 commit comments

Comments
 (0)