mirror of
https://github.com/nlohmann/json.git
synced 2025-07-09 11:01:47 +03:00
reverse iterators
This commit is contained in:
@ -93,7 +93,10 @@ class basic_json
|
||||
using iterator = basic_json::iterator;
|
||||
/// a const iterator for a basic_json container
|
||||
using const_iterator = basic_json::const_iterator;
|
||||
|
||||
/// a reverse iterator for a basic_json container
|
||||
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||
/// a const reverse iterator for a basic_json container
|
||||
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||
|
||||
///////////////////////////
|
||||
// JSON value data types //
|
||||
@ -264,6 +267,8 @@ class basic_json
|
||||
std::enable_if<
|
||||
not std::is_same<V, basic_json::iterator>::value and
|
||||
not std::is_same<V, basic_json::const_iterator>::value and
|
||||
not std::is_same<V, basic_json::reverse_iterator>::value and
|
||||
not std::is_same<V, basic_json::const_reverse_iterator>::value and
|
||||
not std::is_same<V, typename array_t::iterator>::value and
|
||||
not std::is_same<V, typename array_t::const_iterator>::value and
|
||||
std::is_constructible<basic_json, typename V::value_type>::value, int>::type
|
||||
@ -822,6 +827,30 @@ class basic_json
|
||||
return result;
|
||||
}
|
||||
|
||||
/// returns a reverse iterator to the beginning
|
||||
inline reverse_iterator rbegin() noexcept
|
||||
{
|
||||
return reverse_iterator(end());
|
||||
}
|
||||
|
||||
/// returns a reverse iterator to the end
|
||||
inline reverse_iterator rend() noexcept
|
||||
{
|
||||
return reverse_iterator(begin());
|
||||
}
|
||||
|
||||
/// returns a reverse iterator to the beginning
|
||||
inline const_reverse_iterator crbegin() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(cend());
|
||||
}
|
||||
|
||||
/// returns a reverse iterator to the end
|
||||
inline const_reverse_iterator crend() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(cbegin());
|
||||
}
|
||||
|
||||
|
||||
//////////////
|
||||
// capacity //
|
||||
|
Reference in New Issue
Block a user