Skip to content

Commit

Permalink
fixup! feat: ScopedTimer accept numeric arguments as formatstring arg…
Browse files Browse the repository at this point in the history
…uments
  • Loading branch information
Swiftb0y committed May 15, 2024
1 parent 6ea997c commit 7236833
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/util/qstringformat.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ static constexpr bool is_convertible_to_view_or_qstring_v =

// check if we can call QString::number(T) with T
template<typename T>
inline constexpr bool is_number_compatible_v =
static constexpr bool is_number_compatible_v =
std::is_invocable_v<decltype(QString::number(std::declval<T>()))(T), T>;

// always false, used for static_assert and workaround for compilers without
// https://cplusplus.github.io/CWG/issues/2518.html
template<typename T>
static constexpr bool always_false_v = false;
} // namespace

// Try to convert T to a type that would be accepted by QString::args(Args&&...)
Expand All @@ -28,7 +33,7 @@ auto convertToQStringConvertible(T&& arg) {
} else if constexpr (is_number_compatible_v<T>) {
return QString::number(std::forward<T>(arg));
} else {
static_assert(false, "Unsupported type for QString::arg");
static_assert(always_false_v<T>, "Unsupported type for QString::arg");
// unreachable, but returning a QString results in a better error message
// because the log won't be spammed with all the QString::arg overloads
// it couldn't match with `void`.
Expand Down

0 comments on commit 7236833

Please sign in to comment.