Skip to content

Commit 6b4a20a

Browse files
committed
New
1 parent 1c5e739 commit 6b4a20a

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

doc/ref/basic_value/empty.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
### `tao::json::basic_value::empty`
2+
3+
```c++
4+
bool empty() const; // (1)
5+
```
6+
7+
Returns whether the instance is considered "empty". An instance is considered empty if it is
8+
9+
* of type [`UNINITIALIZED`](../type.md#UNINITIALIZED), or
10+
* of type [`STRING`](../type.md#STRING) and the embedded `std::string` is empty, or
11+
* of type [`ARRAY`](../type.md#ARRAY) and the embedded `std::vector` is empty, or
12+
* of type [`OBJECT`](../type.md#OBJECT) and the embedded `std::map` is empty, or
13+
* of type [`RAW_PTR`](../type.md#RAW_PTR) and the embedded raw pointer is equal to `nullptr`
14+
15+
#### Preconditions
16+
17+
The instance must *not* be in a discarded state. The precondition *may* be checked by the implementation with `assert`.
18+
19+
#### Return value
20+
21+
`true` when the instance is considered empty, `true` otherwise.
22+
23+
#### Exceptions
24+
25+
1. `noexcept`
26+
27+
#### Complexity
28+
29+
1. Constant
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
### `tao::json::basic_value::operator bool`
2+
3+
```c++
4+
explicit operator bool() const; // (1)
5+
```
6+
7+
Returns whether the instance has been initialized. Note that an initialized value might become an uninitialized value by calling `reset()` or by assigning from another uninitialized value.
8+
9+
#### Preconditions
10+
11+
The instance must *not* be in a discarded state. This precondition *might* be checked by the implementation with an `assert`.
12+
13+
#### Return value
14+
15+
`false` when the instance is of type [`UNINITIALIZED`](../type.md#UNINITIALIZED), `true` otherwise.
16+
17+
#### Exceptions
18+
19+
1. `noexcept`
20+
21+
#### Complexity
22+
23+
1. Constant
24+
25+
#### Possible implementation
26+
27+
```c++
28+
explicit operator bool() const noexcept
29+
{
30+
assert( type() != json::type::DISCARDED );
31+
return type() != json::type::UNINITIALIZED;
32+
}
33+
```

0 commit comments

Comments
 (0)