! @brief checks whether the container is empty. Checks if a JSON value has no elements (i.e. whether its @ref size is `0`). @return The return value depends on the different types and is defined as follows: Value type | return value ----------- | ------------- null | `true` boolean
| 21418 | @since version 1.0.0 |
| 21419 | */ |
| 21420 | bool empty() const noexcept |
| 21421 | { |
| 21422 | switch (m_type) |
| 21423 | { |
| 21424 | case value_t::null: |
| 21425 | { |
| 21426 | // null values are empty |
| 21427 | return true; |
| 21428 | } |
| 21429 | |
| 21430 | case value_t::array: |
| 21431 | { |
| 21432 | // delegate call to array_t::empty() |
| 21433 | return m_value.array->empty(); |
| 21434 | } |
| 21435 | |
| 21436 | case value_t::object: |
| 21437 | { |
| 21438 | // delegate call to object_t::empty() |
| 21439 | return m_value.object->empty(); |
| 21440 | } |
| 21441 | |
| 21442 | default: |
| 21443 | { |
| 21444 | // all other types are nonempty |
| 21445 | return false; |
| 21446 | } |
| 21447 | } |
| 21448 | } |
| 21449 | |
| 21450 | /*! |
| 21451 | @brief returns the number of elements |
no test coverage detected