Thoth
A functional, expressive, asynchronous C++26 webdev library
Loading...
Searching...
No Matches
Utils.hpp
Go to the documentation of this file.
1#pragma once
2
3namespace Thoth::NJson {
4 // I really don't know why I made this two
5
6 template<class ...T>
7 requires (std::constructible_from<Json::Value, T>, ...)
8 Array MakeArray(T&&... ts) {
9 Array arr{};
10 arr.reserve(sizeof...(T));
11
12 (arr.emplace_back(std::forward<T>(ts)), ...);
13
14 return arr;
15 }
16
17 template<class... P>
18 requires (std::constructible_from<Json, typename P::second_type> && ...)
20 return JsonObject{
22 std::forward<P>(ts).first,
23 Json{ std::forward<P>(ts).second }
24 )...
25 };
26 }
27}
Definition Definitions.hpp:19
std::vector< Json > Array
Definition Definitions.hpp:29
Array MakeArray(T &&... ts)
Definition Utils.hpp:8
JsonObject MakeObject(P &&... ts)
Definition Utils.hpp:19
Definition Json.hpp:16
Definition JsonObject.hpp:14
std::pair< JsonObjKey, Json > JsonPair
Definition JsonObject.hpp:17