@@ -585,20 +585,20 @@ class JSON_API Value {
585
585
iterator begin ();
586
586
iterator end ();
587
587
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 ;
591
591
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.
598
594
Value& front ();
599
595
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.
602
602
Value& back ();
603
603
604
604
// Accessors for the [start, limit) range of bytes within the JSON text from
@@ -941,6 +941,14 @@ class JSON_API ValueIterator : public ValueIteratorBase {
941
941
942
942
inline void swap (Value& a, Value& b) { a.swap (b); }
943
943
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
+
944
952
} // namespace Json
945
953
946
954
#pragma pack(pop)
0 commit comments