! @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 | `false` string
| 17242 | @since version 1.0.0 |
| 17243 | */ |
| 17244 | bool empty() const noexcept |
| 17245 | { |
| 17246 | switch (m_type) |
| 17247 | { |
| 17248 | case value_t::null: |
| 17249 | { |
| 17250 | // null values are empty |
| 17251 | return true; |
| 17252 | } |
| 17253 | |
| 17254 | case value_t::array: |
| 17255 | { |
| 17256 | // delegate call to array_t::empty() |
| 17257 | return m_value.array->empty(); |
| 17258 | } |
| 17259 | |
| 17260 | case value_t::object: |
| 17261 | { |
| 17262 | // delegate call to object_t::empty() |
| 17263 | return m_value.object->empty(); |
| 17264 | } |
| 17265 | |
| 17266 | default: |
| 17267 | { |
| 17268 | // all other types are nonempty |
| 17269 | return false; |
| 17270 | } |
| 17271 | } |
| 17272 | } |
| 17273 | |
| 17274 | /*! |
| 17275 | @brief returns the number of elements |
no test coverage detected