summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-12-09 14:21:26 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2016-12-09 14:21:26 +0000
commit595b63672bb8e8a40af06c0bc32e5ee432697793 (patch)
tree49c9335ffc48eb9b855b5eae1fed55199e625a84
parentSimplify the upto buffer (diff)
downloadlibadhocutil-595b63672bb8e8a40af06c0bc32e5ee432697793.tar.bz2
libadhocutil-595b63672bb8e8a40af06c0bc32e5ee432697793.tar.xz
libadhocutil-595b63672bb8e8a40af06c0bc32e5ee432697793.zip
Simplify the upto writers
-rw-r--r--libadhocutil/compileTimeFormatter.h44
1 files changed, 9 insertions, 35 deletions
diff --git a/libadhocutil/compileTimeFormatter.h b/libadhocutil/compileTimeFormatter.h
index 64581ea..1543058 100644
--- a/libadhocutil/compileTimeFormatter.h
+++ b/libadhocutil/compileTimeFormatter.h
@@ -23,51 +23,25 @@ namespace AdHoc {
return Upto<S, stop, start, offset + 1, sn...>::stuff(s, Buffer<len, sm..., s0>());
}
};
- template <const char * const & S, char stop, int start, int offset, char... sn>
- struct Upto<S, stop, start, offset, stop, sn...> {
+ template <const char * const & S, int start, char... sn>
+ struct UptoWrite {
template<typename stream, int len, char... sm>
static auto stuff(stream & s, const Buffer<len, sm...> &)
{
s.write(S + start, sizeof...(sm));
- return Buffer<sizeof...(sm), stop, sn...>();
+ return Buffer<sizeof...(sm), sn...>();
}
};
template <const char * const & S, char stop, int start, int offset, char... sn>
- struct Upto<S, stop, start, offset, 0, sn...> {
- template<typename stream, int len, char... sm>
- static auto stuff(stream & s, const Buffer<len, sm...> &)
- {
- s.write(S + start, sizeof...(sm));
- return Buffer<sizeof...(sm), 0, sn...>();
- }
- };
+ struct Upto<S, stop, start, offset, stop, sn...> : public UptoWrite<S, start, stop, sn...> { };
+ template <const char * const & S, char stop, int start, int offset, char... sn>
+ struct Upto<S, stop, start, offset, 0, sn...> : public UptoWrite<S, start, 0, sn...> { };
template <const char * const & S, char stop, int start, char s0, char... sn>
- struct Upto<S, stop, start, WRAP_AT, s0, sn...> {
- template<typename stream, int len, char... sm>
- static auto stuff(stream & s, const Buffer<len, sm...> &)
- {
- s.write(S + start, sizeof...(sm));
- return Buffer<sizeof...(sm), s0, sn...>();
- }
- };
+ struct Upto<S, stop, start, WRAP_AT, s0, sn...> : public UptoWrite<S, start, s0, sn...> { };
template <const char * const & S, char stop, int start, char... sn>
- struct Upto<S, stop, start, WRAP_AT, stop, sn...> {
- template<typename stream, int len, char... sm>
- static auto stuff(stream & s, const Buffer<len, sm...> &)
- {
- s.write(S + start, sizeof...(sm));
- return Buffer<sizeof...(sm), stop, sn...>();
- }
- };
+ struct Upto<S, stop, start, WRAP_AT, stop, sn...> : public UptoWrite<S, start, stop, sn...> { };
template <const char * const & S, char stop, int start, char... sn>
- struct Upto<S, stop, start, WRAP_AT, 0, sn...> {
- template<typename stream, int len, char... sm>
- static auto stuff(stream & s, const Buffer<len, sm...> &)
- {
- s.write(S + start, sizeof...(sm));
- return Buffer<sizeof...(sm), 0, sn...>();
- }
- };
+ struct Upto<S, stop, start, WRAP_AT, 0, sn...> : public UptoWrite<S, start, 0, sn...> { };
template <const char * const & S, int start, typename stream, char ... sn>
struct StreamWriter {