Skip to content

Commit e9a5ddb

Browse files
committed
chore: addresses review comments
1 parent 20be481 commit e9a5ddb

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

Diff for: include/json/value.h

+19-11
Original file line numberDiff line numberDiff line change
@@ -585,20 +585,20 @@ class JSON_API Value {
585585
iterator begin();
586586
iterator end();
587587

588-
/// @brief Returns a reference to the first element in the container.
589-
/// Calling front on an empty container is undefined behavior.
590-
Value const& front() const;
588+
/// \brief Returns a reference to the first element in the `Value`.
589+
/// Requires that this value holds an array or json object, with at least one element.
590+
const Value& front() const;
591591

592-
/// @brief Returns a reference to the last element in the container.
593-
/// Calling back on an empty container is undefined behavior.
594-
Value const& back() const;
595-
596-
/// @brief Returns a reference to the first element in the container.
597-
/// Calling front on an empty container is undefined behavior.
592+
/// \brief Returns a reference to the first element in the `Value`.
593+
/// Requires that this value holds an array or json object, with at least one element.
598594
Value& front();
599595

600-
/// @brief Returns a reference to the last element in the container.
601-
/// Calling back on an empty container is undefined behavior.
596+
/// \brief Returns a reference to the last element in the `Value`.
597+
/// Requires that value holds an array or json object, with at least one element.
598+
const Value& back() const;
599+
600+
/// \brief Returns a reference to the last element in the `Value`.
601+
/// Requires that this value holds an array or json object, with at least one element.
602602
Value& back();
603603

604604
// Accessors for the [start, limit) range of bytes within the JSON text from
@@ -941,6 +941,14 @@ class JSON_API ValueIterator : public ValueIteratorBase {
941941

942942
inline void swap(Value& a, Value& b) { a.swap(b); }
943943

944+
inline const Value& Value::front() const { return *begin(); }
945+
946+
inline Value& Value::front() { return *begin(); }
947+
948+
inline const Value& Value::back() const { return *(--end()); }
949+
950+
inline Value& Value::back() { return *(--end()); }
951+
944952
} // namespace Json
945953

946954
#pragma pack(pop)

Diff for: src/lib_json/json_value.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -1495,14 +1495,6 @@ Value::iterator Value::end() {
14951495
return iterator();
14961496
}
14971497

1498-
Value const& Value::front() const { return *begin(); }
1499-
1500-
Value& Value::front() { return *begin(); }
1501-
1502-
Value const& Value::back() const { return *(--end()); }
1503-
1504-
Value& Value::back() { return *(--end()); }
1505-
15061498
// class PathArgument
15071499
// //////////////////////////////////////////////////////////////////
15081500

0 commit comments

Comments
 (0)