![]() |
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:
key_value_pair kvp( "num" , 42); string_view key = get<0>(kvp); value& jv = get<1>(kvp);
When using C++17 or greater, objects of type key_value_pair may be used to initialize
structured bindings:
key_value_pair kvp( "num" , 42); auto & [key, 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>