mirror of
https://github.com/nlohmann/json.git
synced 2025-07-28 12:02:00 +03:00
implemented front() and back()
This commit is contained in:
@ -1263,6 +1263,34 @@ class basic_json
|
||||
return m_value.object->operator[](key);
|
||||
}
|
||||
|
||||
/// access the first element
|
||||
inline reference front()
|
||||
{
|
||||
return *begin();
|
||||
}
|
||||
|
||||
/// access the first element
|
||||
inline const_reference front() const
|
||||
{
|
||||
return *cbegin();
|
||||
}
|
||||
|
||||
/// access the last element
|
||||
inline reference back()
|
||||
{
|
||||
auto tmp = end();
|
||||
--tmp;
|
||||
return *tmp;
|
||||
}
|
||||
|
||||
/// access the last element
|
||||
inline const_reference back() const
|
||||
{
|
||||
auto tmp = cend();
|
||||
--tmp;
|
||||
return *tmp;
|
||||
}
|
||||
|
||||
/// remove element given an iterator
|
||||
template <class T, typename
|
||||
std::enable_if<
|
||||
|
Reference in New Issue
Block a user