diff --git a/include/ircd/exception.h b/include/ircd/exception.h index 242299efa..d6f3b7e6b 100644 --- a/include/ircd/exception.h +++ b/include/ircd/exception.h @@ -55,8 +55,8 @@ struct exception char buf[BUFSIZE]; - ssize_t generate(const char *const &name, const char *const &fmt, va_list ap) noexcept; - ssize_t generate(const char *const &fmt, va_list ap) noexcept; + ssize_t generate(const char *const &name, const char *const &fmt, const va_rtti &ap) noexcept; + ssize_t generate(const char *const &fmt, const va_rtti &ap) noexcept; public: const char *what() const noexcept override @@ -106,13 +106,11 @@ struct exception struct name \ :parent \ { \ - name(const char *const fmt = " ", ...) noexcept AFP(2, 3) \ + template \ + name(const char *const fmt = " ", args&&... ap) noexcept \ :parent{generate_skip} \ { \ - va_list ap; \ - va_start(ap, fmt); \ - generate(#name, fmt, ap); \ - va_end(ap); \ + generate(#name, fmt, va_rtti{std::forward(ap)...}); \ } \ \ name(const generate_skip_t) noexcept \ @@ -125,13 +123,11 @@ struct name \ struct name \ :parent \ { \ - name(const char *const fmt, ...) noexcept AFP(2, 3) \ - parent{generate_skip_t} \ + template \ + name(const char *const fmt = " ", args&&... ap) noexcept \ + :parent{generate_skip_t} \ { \ - va_list ap; \ - va_start(ap, fmt); \ - generate(fmt, ap); \ - va_end(ap); \ + generate(fmt, va_rtti{std::forward(ap)...}); \ } \ \ name(const generate_skip_t = {}) noexcept \ diff --git a/ircd/exception.cc b/ircd/exception.cc index e2659db47..783275685 100644 --- a/ircd/exception.cc +++ b/ircd/exception.cc @@ -23,20 +23,18 @@ * */ -using namespace ircd; - ssize_t -exception::generate(const char *const &fmt, - va_list ap) +ircd::exception::generate(const char *const &fmt, + const va_rtti &ap) noexcept { - return vsnprintf(buf, sizeof(buf), fmt, ap); + return fmt::vsnprintf(buf, sizeof(buf), fmt, ap); } ssize_t -exception::generate(const char *const &name, - const char *const &fmt, - va_list ap) +ircd::exception::generate(const char *const &name, + const char *const &fmt, + const va_rtti &ap) noexcept { size_t size(0); @@ -44,7 +42,7 @@ noexcept size = strlcat(buf, name, sizeof(buf)); size = strlcat(buf, empty? "." : ": ", sizeof(buf)); if(size < sizeof(buf)) - size += vsnprintf(buf + size, sizeof(buf) - size, fmt, ap); + size += fmt::vsnprintf(buf + size, sizeof(buf) - size, fmt, ap); return size; }