2021-05-02 02:40:35 +08:00
|
|
|
// IWYU pragma: private, include "ftxui/dom/elements.hpp"
|
2019-01-06 23:14:19 +08:00
|
|
|
#include <type_traits>
|
|
|
|
|
2019-01-23 09:16:00 +08:00
|
|
|
template <class T>
|
2020-02-16 03:41:44 +08:00
|
|
|
void Merge(Elements&, T) {}
|
2019-01-23 09:16:00 +08:00
|
|
|
|
|
|
|
template <>
|
|
|
|
inline void Merge(Elements& container, Element element) {
|
|
|
|
container.push_back(std::move(element));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
inline void Merge(Elements& container, Elements elements) {
|
2020-03-24 04:26:00 +08:00
|
|
|
for (auto& element : elements)
|
2019-01-23 09:16:00 +08:00
|
|
|
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.
|
2020-03-24 04:26:00 +08:00
|
|
|
#define TAKE_ANY_ARGS(container) \
|
|
|
|
template <class... Args> \
|
|
|
|
Element container(Args... children) { \
|
|
|
|
return container(unpack(std::forward<Args>(children)...)); \
|
|
|
|
}
|
2020-08-16 06:24:18 +08:00
|
|
|
|
|
|
|
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
|
|
|
// Use of this source code is governed by the MIT license that can be found in
|
|
|
|
// the LICENSE file.
|