| 12345678910111213141516171819202122232425 |
- //
- // serial.tpp
- // danmaku
- //
- // Created by Sam Jaffe on 5/27/19.
- // Copyright © 2019 Sam Jaffe. All rights reserved.
- //
- #pragma once
- #include <json/json.h>
- #include <vector>
- namespace danmaku {
- template <typename F, typename... Args>
- auto to_vector(Json::Value const & json, F && func, Args &&... args)
- -> std::vector<decltype(func(json, args...))> {
- std::vector<decltype(func(json, args...))> out;
- out.reserve(json.size());
- for (int i = 0; i < json.size(); ++i) {
- out.emplace_back(func(json[i], args...));
- }
- return out;
- }
- }
|