diff options
Diffstat (limited to 'include/core/Defs.hpp')
-rw-r--r-- | include/core/Defs.hpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/include/core/Defs.hpp b/include/core/Defs.hpp index 4b73cfa..245e32c 100644 --- a/include/core/Defs.hpp +++ b/include/core/Defs.hpp @@ -58,6 +58,42 @@ enum class Error { ERR_WTF = ERR_OMFG_THIS_IS_VERY_VERY_BAD ///< short version of the above }; + namespace helpers { + template <typename T, typename ValueT> + T append_all (T appendable, ValueT value) { + appendable.append(value); + return appendable; + } + + template <typename T, typename ValueT, typename... Args> + T append_all (T appendable, ValueT value, Args... args) { + appendable.append(value); + return append_all(appendable, args...); + } + + template <typename T> + T append_all (T appendable) { + return appendable; + } + + template <typename KV, typename KeyT, typename ValueT> + KV add_all (KV kv, KeyT key, ValueT value) { + kv[key] = value; + return kv; + } + + template <typename KV, typename KeyT, typename ValueT, typename... Args> + KV add_all (KV kv, KeyT key, ValueT value, Args... args) { + kv[key] = value; + return add_all(kv, args...); + } + + template <typename KV> + KV add_all (KV kv) { + return kv; + } + } + } #include <stdio.h> |