deploy: 098eebd412
This commit is contained in:
1 parent
70feeb496c
commit
8279f43a4b
471 files changed
+1737
-1335
No files matched your search
@@ -2,12 +2,17 @@
|
||||
|
||||
```
|
||||
namespace std {
|
||||
void swap(nlohmann::basic_json& j1, nlohmann::basic_json& j2);
|
||||
void swap(nlohmann::basic_json& j1, nlohmann::basic_json& j2) noexcept(
|
||||
is_nothrow_move_constructible<nlohmann::basic_json>::value &&
|
||||
is_nothrow_move_assignable<nlohmann::basic_json>::value
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
Exchanges the values of two JSON objects.
|
||||
|
||||
This specialization is only provided before C++20, which no longer allows specializing function templates in namespace `std`. With C++20 (and in generic code with any standard), use the idiom `using std::swap; swap(j1, j2);`: it finds the [`swap`](https://json.nlohmann.me/api/basic_json/swap/index.md) friend function (overload 2) by argument-dependent lookup. A qualified `std::swap(j1, j2)` still compiles with C++20, but uses the generic `std::swap`, which swaps by three moves instead of exchanging the contents.
|
||||
|
||||
## Parameters
|
||||
|
||||
`j1` (in, out) : value to be replaced by `j2`
|
||||
@@ -16,7 +21,7 @@ Exchanges the values of two JSON objects.
|
||||
|
||||
## Exception safety
|
||||
|
||||
No-throw guarantee: this function never throws exceptions.
|
||||
No-throw guarantee if the `noexcept` condition above holds: it holds unless moving the [`json_base_class_t`](https://json.nlohmann.me/api/basic_json/json_base_class_t/index.md) can throw. With the default base class, this function never throws exceptions.
|
||||
|
||||
## Complexity
|
||||
|
||||
@@ -74,3 +79,4 @@ j1 = [1,2,4,8,16] | j2 = {"one":1,"two":2}
|
||||
|
||||
- Added in version 1.0.0.
|
||||
- Extended for arbitrary basic_json types in version 3.10.5.
|
||||
- Not provided with C++20 since version 3.9.0.
|
||||
Reference in new issue
Block a user