|
JSON Voorhees
Killer JSON for C++
|
What dereferencing an object_iterator (TValue of value) or a const_object_iterator (TValue of const value) gives: references to the key and value of one member.
More...
#include <jsonv/value.hpp>
Collaboration diagram for jsonv::value::basic_object_reference< TValue >:Public Types | |
| using | first_type = const std::string |
The type of first, as in std::pair, which this stands in for. | |
| using | second_type = TValue |
The type of second, as in std::pair. | |
Public Member Functions | |
| basic_object_reference (const std::string &key, TValue &val) noexcept | |
| Refer to key and val. | |
| basic_object_reference (std::conditional_t< std::is_const_v< TValue >, const object_value_type &, object_value_type & > pair) noexcept | |
| Refer to the key and value of pair. | |
| template<typename UValue , typename = std::enable_if_t< !std::is_same_v<UValue, TValue> && std::is_convertible_v<UValue&, TValue&> >> | |
| basic_object_reference (const basic_object_reference< UValue > &source) noexcept | |
This allows conversion from an object_reference to a const_object_reference. | |
| template<typename TPair , typename = std::enable_if_t<std::is_same_v<TPair, object_value_type>>> | |
| operator TPair () const | |
| Copy the member into an object_value_type. | |
Public Attributes | |
| const std::string & | first |
| The key of the member. | |
| TValue & | second |
| The value of the member. | |
What dereferencing an object_iterator (TValue of value) or a const_object_iterator (TValue of const value) gives: references to the key and value of one member.
Like the reference of std::flat_map, it is a proxy returned by value, so auto& m : obj.as_object() does not compile – write auto&& m, const auto& m or auto&& [key, val]. The key is always const, since changing it would break the order members are kept in.
The conversion to object_value_type is explicit because it copies the value. A loop written as const value::object_value_type& m : obj.as_object() – which before members were stored contiguously bound straight to the member – would otherwise still compile and deep-copy every one of them.
| using jsonv::value::basic_object_reference< TValue >::first_type = const std::string |
| using jsonv::value::basic_object_reference< TValue >::second_type = TValue |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineexplicit |
Copy the member into an object_value_type.
| TPair | Always object_value_type. It is a parameter so that nothing names that pair until the conversion is used: MSVC instantiates a type a template's body names when it reads the body, and here that is before value is complete. |
| const std::string& jsonv::value::basic_object_reference< TValue >::first |
| TValue& jsonv::value::basic_object_reference< TValue >::second |