osh.h

My personal stdc++ replacement
git clone git://git.oshgnacknak.de/osh.h.git
Log | Files | Refs

commit c06258fc0d56ebb455ae4394f635c7a2262ceb8c
parent d8c4f1b6c689562fbb5431dca39fb4b271998767
Author: Oshgnacknak <osh@oshgnacknak.de>
Date:   Sat, 25 Dec 2021 12:21:51 +0100

Remove dependency on stdarg

Diffstat:
Mosh.h | 14++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/osh.h b/osh.h @@ -2,7 +2,6 @@ #define OSH_H #include <stdio.h> -#include <stdarg.h> namespace osh { @@ -21,7 +20,9 @@ namespace osh { public: FileFormatter(FILE* stream); - void format(const char* fmt, ...); + + template<typename... Args> + void format(const char* fmt, Args...); }; extern FileFormatter fout; @@ -121,12 +122,9 @@ namespace osh { FileFormatter::FileFormatter(FILE* stream) : stream(stream) {} - void FileFormatter::format(const char* fmt, ...) { - va_list ap; - va_start(ap, fmt); - - vfprintf(stream, fmt, ap); - va_end(ap); + template<typename... Args> + void FileFormatter::format(const char* fmt, Args... args) { + fprintf(stream, fmt, args...); } }