-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Closed
Labels
solution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation
Description
Describe the feature in as much detail as possible.
A null coalescing function, similar to that of the null coalescing operator found in most modern languages (?? in C#, ?: in Kotlin, || in JS almost). Except in here it would be a template function named or, or something similar.
I believe this would make code a bit cleaner, as there would be less ifs and temporary variables scattered around the place.
Include sample usage where appropriate.
#include"json.hpp"
#include<iostream>
int main() {
nlohmann::json j = R"({"x": 5, "y": null})"_json;
std::cout << j["x"].or(29) << ' ' << j["y"].or(10) << std::flush;
}
Expected output would be:
5 10
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
solution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation