deploy: 4155e2938f
This commit is contained in:
1 parent
be4d0a6f4b
commit
90f0c9d411
714 files changed
+22067
-622
No files matched your search
@@ -0,0 +1,24 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <nlohmann/json_view.hpp>
|
||||
|
||||
using json_document = nlohmann::json_document;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << std::boolalpha;
|
||||
|
||||
std::string text = R"({"a": 1})";
|
||||
|
||||
// borrowed: the document only points into `text`; `text` must outlive it
|
||||
json_document borrowed = json_document::parse(text);
|
||||
std::cout << borrowed.owns_source() << '\n';
|
||||
|
||||
// owned: parse_copy() always takes its own copy
|
||||
json_document copied = json_document::parse_copy(text);
|
||||
std::cout << copied.owns_source() << '\n';
|
||||
|
||||
// owned: an rvalue std::string is moved in, not copied, but still owned
|
||||
json_document moved_in = json_document::parse(std::string(text));
|
||||
std::cout << moved_in.owns_source() << '\n';
|
||||
}
|
||||
Reference in new issue
Block a user