mirror of
https://github.com/nlohmann/json.git
synced 2026-10-05 22:05:49 +01:00
deploy: d8d47be4a5
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -20,6 +20,14 @@ The default value for `CustomBaseClass` is `void`. In this case, an [empty base
|
||||
|
||||
The type `CustomBaseClass` has to be a default-constructible, non-`final` class. `basic_json` only supports copy/move construction/assignment if `CustomBaseClass` does so as well. A `CustomBaseClass` with non-static data members forfeits `basic_json`'s [standard layout](https://en.cppreference.com/w/cpp/named_req/StandardLayoutType) guarantee. See [Template Parameter Requirements](https://json.nlohmann.me/features/types/template_parameters/#custombaseclass).
|
||||
|
||||
#### Name conflicts
|
||||
|
||||
Since `basic_json` derives from `CustomBaseClass`, members of `basic_json` hide members of `CustomBaseClass` with the same name. Hidden members remain accessible via [`as_base_class`](https://json.nlohmann.me/api/basic_json/as_base_class/index.md) or by casting the value to `json_base_class_t`.
|
||||
|
||||
Avoid generic member names
|
||||
|
||||
Future versions of the library may add members to `basic_json` that hide members of `CustomBaseClass` that are accessible today. To reduce the risk of such conflicts, avoid generic names for the members of `CustomBaseClass`, for instance by using a distinctive prefix.
|
||||
|
||||
## Examples
|
||||
|
||||
Example
|
||||
@@ -128,8 +136,10 @@ Output:
|
||||
|
||||
## See also
|
||||
|
||||
- [as_base_class](https://json.nlohmann.me/api/basic_json/as_base_class/index.md) - access the custom base class
|
||||
- [Template Parameter Requirements](https://json.nlohmann.me/features/types/template_parameters/#custombaseclass) - the requirements for `CustomBaseClass`
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.12.0.
|
||||
- Made a public member type in version 3.13.0 unreleased; it was private before, so it could not be named outside the class.
|
||||
|
||||
Reference in New Issue
Block a user