2019-01-06 23:14:19 +08:00
|
|
|
#include <type_traits>
|
|
|
|
|
2019-01-23 09:16:00 +08:00
|
|
|
template <class T>
|
|
|
|
void Merge(Elements& container, T t) {}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
inline void Merge(Elements& container, Element element) {
|
|
|
|
container.push_back(std::move(element));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
inline void Merge(Elements& container, Elements elements) {
|
|
|
|
for(auto& element : elements)
|
|
|
|
container.push_back(std::move(element));
|
|
|
|
}
|
|
|
|
|
2019-01-06 23:14:19 +08:00
|
|
|
// Turn a set of arguments into a vector.
|
|
|
|
template <class... Args>
|
2019-01-13 01:24:46 +08:00
|
|
|
Elements unpack(Args... args) {
|
2019-01-23 09:16:00 +08:00
|
|
|
std::vector<Element> vec;
|
|
|
|
(Merge(vec, std::move(args)), ...);
|
2019-01-06 23:14:19 +08:00
|
|
|
return vec;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make |container| able to take any number of argments.
|
|
|
|
#define TAKE_ANY_ARGS(container) \
|
2019-01-23 09:16:00 +08:00
|
|
|
template <class... Args> \
|
|
|
|
Element container(Args... children) { \
|
|
|
|
return container(unpack(std::forward<Args>(children)...)); \
|
|
|
|
}
|