diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-12-09 14:06:50 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-12-09 14:07:49 +0000 |
commit | 05c2137e867737f3b5903ec5884028dfec1dce56 (patch) | |
tree | b46e489eb4778b33d4782d553617384aa54acda6 | |
parent | Pass format string as template argument into writer to avoid copying out byte... (diff) | |
download | libadhocutil-05c2137e867737f3b5903ec5884028dfec1dce56.tar.bz2 libadhocutil-05c2137e867737f3b5903ec5884028dfec1dce56.tar.xz libadhocutil-05c2137e867737f3b5903ec5884028dfec1dce56.zip |
Simplify parser templates
-rw-r--r-- | libadhocutil/compileTimeFormatter.h | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/libadhocutil/compileTimeFormatter.h b/libadhocutil/compileTimeFormatter.h index 1a09bb1..d45d662 100644 --- a/libadhocutil/compileTimeFormatter.h +++ b/libadhocutil/compileTimeFormatter.h @@ -144,41 +144,26 @@ namespace AdHoc { } }; - template <const char * const & S, int offset, char s0, char ... sn> - struct Parser<S, offset, WRAP_AT, s0, sn...> { + template <const char * const & S, bool more, char ... sn> + struct ParserBase { static auto parse() { - return Buffer<true, 0, sn..., s0>(); + return innerparse(); } static auto innerparse() { - return Buffer<true, 0, sn..., s0>(); + return Buffer<more, 0, sn...>(); } }; + template <const char * const & S, int offset, char s0, char ... sn> + struct Parser<S, offset, WRAP_AT, s0, sn...> : public ParserBase<S, true, sn..., s0> { }; + template <const char * const & S, int offset, char ... sn> - struct Parser<S, offset, WRAP_AT, 0, sn...> { - static auto parse() - { - return Buffer<false, 0, sn...>(); - } - static auto innerparse() - { - return Buffer<false, 0, sn...>(); - } - }; + struct Parser<S, offset, WRAP_AT, 0, sn...> : public ParserBase<S, true, sn..., 0> { }; template <const char * const & S, int offset, int roffset, char ... sn> - struct Parser<S, offset, roffset, 0, sn...> { - static auto parse() - { - return Buffer<false, 0, sn..., 0>(); - } - static auto innerparse() - { - return Buffer<false, 0, sn..., 0>(); - } - }; + struct Parser<S, offset, roffset, 0, sn...> : public ParserBase<S, false, sn..., 0>{ }; template <const char * const & S> struct Formatter { |