Skip to content

Commit 09dbb3e

Browse files
[Support] Use a C++17 fold expression in a static_assert (NFC) (#161479)
This patch simplifies a recursive use of a type trait to a C++17 fold expression.
1 parent 190826c commit 09dbb3e

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

llvm/include/llvm/Support/Format.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,6 @@ class LLVM_ABI format_object_base {
7878
/// printed, this synthesizes the string into a temporary buffer provided and
7979
/// returns whether or not it is big enough.
8080

81-
// Helper to validate that format() parameters are scalars or pointers.
82-
template <typename... Args> struct validate_format_parameters;
83-
template <typename Arg, typename... Args>
84-
struct validate_format_parameters<Arg, Args...> {
85-
static_assert(std::is_scalar_v<Arg>,
86-
"format can't be used with non fundamental / non pointer type");
87-
validate_format_parameters() { validate_format_parameters<Args...>(); }
88-
};
89-
template <> struct validate_format_parameters<> {};
90-
9181
template <typename... Ts>
9282
class format_object final : public format_object_base {
9383
std::tuple<Ts...> Vals;
@@ -105,7 +95,9 @@ class format_object final : public format_object_base {
10595
public:
10696
format_object(const char *fmt, const Ts &... vals)
10797
: format_object_base(fmt), Vals(vals...) {
108-
validate_format_parameters<Ts...>();
98+
static_assert(
99+
(std::is_scalar_v<Ts> && ...),
100+
"format can't be used with non fundamental / non pointer type");
109101
}
110102

111103
int snprint(char *Buffer, unsigned BufferSize) const override {

0 commit comments

Comments
 (0)