Document that shared-storage handles are moved from as owning containers

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-11-22 15:06:08 +01:00
1 parent 595f5fa981
commit bf59461f9b
1 file changed
+4 -2
@@ -83,8 +83,10 @@ basic_json(basic_json&& other) noexcept;
elements are moved from, that is, containers whose elements are `const` when accessed through a `const`
container. Non-owning ranges such as spans or iterator ranges (e.g., `gsl::span`, `std::span`) are copied, so
converting an rvalue span leaves the referenced elements unchanged.
A user-defined view whose elements are `const` through a `const` view, but which does not own them, is
treated as owning; pass such a view as an lvalue to copy the elements.
A user-defined type whose elements are `const` through a `const` object, but which does not own them alone,
is treated as owning: a view, or a handle that shares its storage with other handles (e.g., a wrapper of a
`std::shared_ptr<std::vector<T>>`) and does not copy it before giving non-`const` access. Moving from such
an rvalue changes the elements seen through the other handles; pass it as an lvalue to copy the elements.
- **numbers**: [`number_integer_t`](number_integer_t.md), [`number_unsigned_t`](number_unsigned_t.md),
[`number_float_t`](number_float_t.md), and all convertible number types such as `int`, `size_t`, `int64_t`, `float`
or `double` can be used.