![]() |
Home | Libraries | People | FAQ | More |
Tuple-like element access.
Defined in header <boost/json/value.hpp>
template< std::size_t I, class T> see-below get( T&& kvp);
This overload permits the key and value of a key_value_pair
to be accessed by index. For example:
[link json.ref.boost__json__key_value_pair `key_value_pair`] kvp( "num" , 42); [link json.ref.boost__json__string_view `string_view`] key = get<0>(kvp); [link json.ref.boost__json__value `value`]& jv = get<1>(kvp);
When using C++17 or greater, objects of type key_value_pair may be used to initialize
structured bindings:
[link json.ref.boost__json__key_value_pair `key_value_pair`] kvp( "num" , 42); auto & [key, [link json.ref.boost__json__value `value`]] = kvp;
Depending on the value of I,
the return type will be:
string_view const
if I ==
0, or
value&,
value const&, or value&& if I
== 1.
Any other value for I is
ill-formed.
|
Type |
Description |
|---|---|
|
|
The element index to access. |
std::is_same_v<
std::remove_cvref_t<T>, key_value_pair >
kvp.key() if
I ==
0, or kvp.value() if I
== 1.
|
Name |
Description |
|---|---|
|
|
The |
Convenience header <boost/json.hpp>