From 7316eb87b8ff3b2fa015cb0f2267f6041228b2c2 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 26 Nov 2024 00:55:58 +0200 Subject: [PATCH] BAN: Add requires expression for BAN::Formatter This allows seeing syntax errors before compilation :) --- BAN/include/BAN/Formatter.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/BAN/include/BAN/Formatter.h b/BAN/include/BAN/Formatter.h index 90d53e17..e8fd7a50 100644 --- a/BAN/include/BAN/Formatter.h +++ b/BAN/include/BAN/Formatter.h @@ -10,14 +10,11 @@ namespace BAN::Formatter struct ValueFormat; - template - inline void print(F putc, const char* format); - - template - inline void print(F putc, const char* format, Arg&& arg, Args&&... args); - template - inline void println(F putc, const char* format, Args&&... args); + concept PrintableArguments = requires(F putc, Args&&... args, const ValueFormat& format) + { + (print_argument(putc, BAN::forward(args), format), ...); + }; template inline void print_argument(F putc, T value, const ValueFormat& format); @@ -53,7 +50,7 @@ namespace BAN::Formatter } } - template + template requires PrintableArguments inline void print(F putc, const char* format, Arg&& arg, Args&&... args) { while (*format && *format != '{')