diff --git a/nlohmann::basicjson::max_size.md b/nlohmann::basicjson::max_size.md new file mode 100644 index 0000000..a38365e --- /dev/null +++ b/nlohmann::basicjson::max_size.md @@ -0,0 +1,62 @@ +```cpp +size_type max_size() const; +``` + +## Description + +Returns the type-dependent maximum number of elements the JSON container is able to hold due to system or library implementation limitations, i.e. `std::distance(begin(), end())` for the largest container. + +## Return value + +The return value depends on the different value types and is defined as follows: + +| Value type | return value | +| ---------- | ------------------------ | +| null | `0` | +| boolean | `1` | +| string | `1` | +| number | `1` | +| object | `ObjectType::max_size()` | +| array | `ArrayType::max_size()` | + +## Parameter + +None. + +## Complexity + +Constant, as long as `ArrayType` and `ObjectType` satisfy the [Container concept](http://en.cppreference.com/w/cpp/concept/Container). + +## Exceptions + +None. The function's noexcept-specification is `noexcept`. + +## Notes + +This value is typically equal to `std::numeric_limits::max()`, and reflects the theoretical limit on the size of the container. At runtime, the size of the container may be limited to a value smaller than `max_size()` by the amount of RAM available. + +## Example + +```cpp +#include +#include + +int main() +{ + nlohmann::json array {"string", true, 17, 23.42}; + + std::cout << "Maximum size of a JSON array is " << array.max_size() << "\n"; +} +``` + +Output: + +``` +Maximum size of a JSON array is 1152921504606846975 +``` + +## See also + +- [**size**](https://github.com/nlohmann/json/wiki/nlohmann::basicjson::size)
+returns the number of elements
+_public member function_ \ No newline at end of file