chore: addresses review comments

This commit is contained in:
Jakob 2023-01-30 15:39:44 +01:00
parent 20be481859
commit e9a5ddb081
No known key found for this signature in database
GPG Key ID: 7C9A99A31EDE41C0
2 changed files with 19 additions and 19 deletions

View File

@ -585,20 +585,20 @@ public:
iterator begin(); iterator begin();
iterator end(); iterator end();
/// @brief Returns a reference to the first element in the container. /// \brief Returns a reference to the first element in the `Value`.
/// Calling front on an empty container is undefined behavior. /// Requires that this value holds an array or json object, with at least one element.
Value const& front() const; const Value& front() const;
/// @brief Returns a reference to the last element in the container. /// \brief Returns a reference to the first element in the `Value`.
/// Calling back on an empty container is undefined behavior. /// Requires that this value holds an array or json object, with at least one element.
Value const& back() const;
/// @brief Returns a reference to the first element in the container.
/// Calling front on an empty container is undefined behavior.
Value& front(); Value& front();
/// @brief Returns a reference to the last element in the container. /// \brief Returns a reference to the last element in the `Value`.
/// Calling back on an empty container is undefined behavior. /// Requires that value holds an array or json object, with at least one element.
const Value& back() const;
/// \brief Returns a reference to the last element in the `Value`.
/// Requires that this value holds an array or json object, with at least one element.
Value& back(); Value& back();
// Accessors for the [start, limit) range of bytes within the JSON text from // Accessors for the [start, limit) range of bytes within the JSON text from
@ -941,6 +941,14 @@ public:
inline void swap(Value& a, Value& b) { a.swap(b); } inline void swap(Value& a, Value& b) { a.swap(b); }
inline const Value& Value::front() const { return *begin(); }
inline Value& Value::front() { return *begin(); }
inline const Value& Value::back() const { return *(--end()); }
inline Value& Value::back() { return *(--end()); }
} // namespace Json } // namespace Json
#pragma pack(pop) #pragma pack(pop)

View File

@ -1495,14 +1495,6 @@ Value::iterator Value::end() {
return iterator(); return iterator();
} }
Value const& Value::front() const { return *begin(); }
Value& Value::front() { return *begin(); }
Value const& Value::back() const { return *(--end()); }
Value& Value::back() { return *(--end()); }
// class PathArgument // class PathArgument
// ////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////