mirror of
https://github.com/nlohmann/json.git
synced 2026-10-05 14:10:31 +00:00
1.2 KiB
1.2 KiB
nlohmann::basic_json::as_base_class
json_base_class_t& as_base_class() noexcept;
const json_base_class_t& as_base_class() const noexcept;
Returns a reference to this object as its custom base class json_base_class_t. No copy is
made.
Since basic_json derives from json_base_class_t, a member of basic_json hides any member of the custom base class
with the same name. This function makes such hidden members accessible again.
Return value
reference to this object as json_base_class_t
Exception safety
No-throw guarantee: this function never throws exceptions.
Complexity
Constant.
Notes
The function is equivalent to static_cast<json_base_class_t&>(j) (or static_cast<const json_base_class_t&>(j)).
Examples
??? example
The example shows how to use `as_base_class` to access members of the custom base class that are hidden by members
of `basic_json`.
```cpp
--8<-- "examples/as_base_class.cpp"
```
Output:
```json
--8<-- "examples/as_base_class.output"
```
See also
- json_base_class_t - type of the custom base class
Version history
- Added in version 3.13.0.