mirror of
https://github.com/NixOS/nix
synced 2025-06-27 12:41:15 +02:00
parent
2e2198fd91
commit
02f0294be0
41 changed files with 161 additions and 124 deletions
|
@ -91,12 +91,14 @@ namespace nlohmann {
|
|||
* round trip. We do that with a static assert.
|
||||
*/
|
||||
template<typename T>
|
||||
struct adl_serializer<std::optional<T>> {
|
||||
struct adl_serializer<std::optional<T>>
|
||||
{
|
||||
/**
|
||||
* @brief Convert a JSON type to an `optional<T>` treating
|
||||
* `null` as `std::nullopt`.
|
||||
*/
|
||||
static void from_json(const json & json, std::optional<T> & t) {
|
||||
static void from_json(const json & json, std::optional<T> & t)
|
||||
{
|
||||
static_assert(
|
||||
nix::json_avoids_null<T>::value,
|
||||
"null is already in use for underlying type's JSON");
|
||||
|
@ -109,7 +111,8 @@ struct adl_serializer<std::optional<T>> {
|
|||
* @brief Convert an optional type to a JSON type treating `std::nullopt`
|
||||
* as `null`.
|
||||
*/
|
||||
static void to_json(json & json, const std::optional<T> & t) {
|
||||
static void to_json(json & json, const std::optional<T> & t)
|
||||
{
|
||||
static_assert(
|
||||
nix::json_avoids_null<T>::value,
|
||||
"null is already in use for underlying type's JSON");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue