mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
doc: add reference about try_at
This commit is contained in:
@@ -585,6 +585,27 @@ Throws `std::out_of_range` if the `table` does not contain the specified element
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
### `try_at(key)`
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
result<std::reference_wrapper<value_type>, error_info> try_at(const key_type& key) noexcept;
|
||||||
|
result<std::reference_wrapper<const value_type>, error_info> try_at(const key_type& key) const noexcept;
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Return Value
|
||||||
|
|
||||||
|
After casting the current `value` to a `table`, it returns the element specified by the `key`.
|
||||||
|
|
||||||
|
If successful, it returns a `reference_wrapper` holding a reference to that element.
|
||||||
|
|
||||||
|
If unsuccessful, it returns an `error_info` corresponding to `type_error` or `out_of_range`.
|
||||||
|
|
||||||
|
#### Exceptions
|
||||||
|
|
||||||
|
Does not throw.
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
#### `operator[](key)`
|
#### `operator[](key)`
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
@@ -652,6 +673,26 @@ Throws `toml::type_error` if the stored value is not an `array`.
|
|||||||
|
|
||||||
Throws `std::out_of_range` if the specified element does not exist in the `array`.
|
Throws `std::out_of_range` if the specified element does not exist in the `array`.
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
### `try_at(idx)`
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
result<std::reference_wrapper<value_type>, error_info> try_at(const std::size_t idx) noexcept;
|
||||||
|
result<std::reference_wrapper<const value_type>, error_info> try_at(const std::size_t idx) const noexcept;
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Return Value
|
||||||
|
|
||||||
|
After casting the current `value` to an `array`, it returns the element specified by the `idx`.
|
||||||
|
|
||||||
|
If successful, it returns a `reference_wrapper` holding a reference to that element.
|
||||||
|
|
||||||
|
If unsuccessful, it returns an `error_info` corresponding to `type_error` or `out_of_range`.
|
||||||
|
|
||||||
|
#### Exceptions
|
||||||
|
|
||||||
|
Does not throw.
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@@ -583,6 +583,27 @@ value_type const& at(const key_type& key) const;
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
### `try_at(key)`
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
result<std::reference_wrapper<value_type>, error_info> try_at(const key_type& key) noexcept;
|
||||||
|
result<std::reference_wrapper<const value_type>, error_info> try_at(const key_type& key) const noexcept;
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 戻り値
|
||||||
|
|
||||||
|
今の`value`を`table`にキャストしたあと、`key`によって指定される要素を返します。
|
||||||
|
|
||||||
|
成功した場合、その要素への参照を持つ`reference_wrapper`を返します。
|
||||||
|
|
||||||
|
失敗した場合、 `type_error` または `out_of_range` に対応する `error_info` を返します。
|
||||||
|
|
||||||
|
#### 例外
|
||||||
|
|
||||||
|
投げません。
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
#### `operator[](key)`
|
#### `operator[](key)`
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
@@ -652,6 +673,27 @@ value_type const& at(const std::size_t idx) const;
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
### `try_at(idx)`
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
result<std::reference_wrapper<value_type>, error_info> try_at(const std::size_t idx) noexcept;
|
||||||
|
result<std::reference_wrapper<const value_type>, error_info> try_at(const std::size_t idx) const noexcept;
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 戻り値
|
||||||
|
|
||||||
|
今の`value`を`array`にキャストしたあと、`idx`によって指定される要素を返します。
|
||||||
|
|
||||||
|
成功した場合、その要素への参照を持つ`reference_wrapper`を返します。
|
||||||
|
|
||||||
|
失敗した場合、 `type_error` または `out_of_range` に対応する `error_info` を返します。
|
||||||
|
|
||||||
|
#### 例外
|
||||||
|
|
||||||
|
投げません。
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
### `operator[](idx)`
|
### `operator[](idx)`
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
|
Reference in New Issue
Block a user