🎨 cleanup after PR #395

This commit is contained in:
Niels Lohmann 2016-12-14 22:30:09 +01:00
parent fe00b368ae
commit f24e4f680e
3 changed files with 37 additions and 36 deletions

View file

@ -584,6 +584,7 @@ I deeply appreciate the help of the following people.
- [cgzones](https://github.com/cgzones) had an idea how to fix the Coverity scan.
- [Jared Grubb](https://github.com/jaredgrubb) silenced a nasty documentation warning.
- [Yixin Zhang](https://github.com/qwename) fixed an integer overflow check.
- [Bosswestfalen](https://github.com/Bosswestfalen) merged two iterator classes into a smaller one.
Thanks a lot for helping out!

View file

@ -228,6 +228,7 @@ class basic_json
public:
// forward declarations
template<typename U> class iter_impl;
template<typename Base> class json_reverse_iterator;
class json_pointer;
@ -261,8 +262,6 @@ class basic_json
/// the type of an element const pointer
using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer;
// forward declaration for iterators
template <typename U> class iter_impl;
/// an iterator for a basic_json container
using iterator = iter_impl<basic_json>;
/// a const iterator for a basic_json container
@ -8208,8 +8207,8 @@ class basic_json
/*!
@brief a template for a random access iterator for the @ref basic_json class
This class implements a both iterators (iterator and const_iterator)
for the @ref basic_json class.
This class implements a both iterators (iterator and const_iterator) for the
@ref basic_json class.
@note An iterator is called *initialized* when a pointer to a JSON value
has been set (e.g., by a constructor or a copy assignment). If the
@ -8222,9 +8221,9 @@ class basic_json
The iterator that can be moved to point (forward and backward) to any
element in constant time.
@since version 1.0.0
@since version 1.0.0, simplified in version 2.0.9
*/
template <typename U>
template<typename U>
class iter_impl : public std::iterator<std::random_access_iterator_tag, U>
{
/// allow basic_json to access private members
@ -8242,12 +8241,12 @@ class basic_json
using difference_type = typename basic_json::difference_type;
/// defines a pointer to the type iterated over (value_type)
using pointer = typename std::conditional<std::is_const<U>::value,
typename basic_json::const_pointer,
typename basic_json::pointer>::type;
typename basic_json::const_pointer,
typename basic_json::pointer>::type;
/// defines a reference to the type iterated over (value_type)
using reference = typename std::conditional<std::is_const<U>::value,
typename basic_json::const_reference,
typename basic_json::reference>::type;
typename basic_json::const_reference,
typename basic_json::reference>::type;
/// the category of the iterator
using iterator_category = std::bidirectional_iterator_tag;
@ -8288,19 +8287,19 @@ class basic_json
}
/*
Use operator const_iterator instead of
const_iterator(const iterator& other) noexcept
to avoid two class definitions for iterator and const_iterator.
Use operator `const_iterator` instead of `const_iterator(const iterator&
other) noexcept` to avoid two class definitions for @ref iterator and
@ref const_iterator.
This function is only called if this class is an iterator.
If this class is a const_iterator this function is not called.
This function is only called if this class is an @ref iterator. If this
class is a @ref const_iterator this function is not called.
*/
operator const_iterator() const
{
const_iterator ret;
{
const_iterator ret;
if (m_object)
{
{
ret.m_object = m_object;
ret.m_it = m_it;
}

View file

@ -228,6 +228,7 @@ class basic_json
public:
// forward declarations
template<typename U> class iter_impl;
template<typename Base> class json_reverse_iterator;
class json_pointer;
@ -262,9 +263,9 @@ class basic_json
using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer;
/// an iterator for a basic_json container
class iterator;
using iterator = iter_impl<basic_json>;
/// a const iterator for a basic_json container
class const_iterator;
using const_iterator = iter_impl<const basic_json>;
/// a reverse iterator for a basic_json container
using reverse_iterator = json_reverse_iterator<typename basic_json::iterator>;
/// a const reverse iterator for a basic_json container
@ -8206,8 +8207,8 @@ class basic_json
/*!
@brief a template for a random access iterator for the @ref basic_json class
This class implements a both iterators (iterator and const_iterator)
for the @ref basic_json class.
This class implements a both iterators (iterator and const_iterator) for the
@ref basic_json class.
@note An iterator is called *initialized* when a pointer to a JSON value
has been set (e.g., by a constructor or a copy assignment). If the
@ -8220,9 +8221,9 @@ class basic_json
The iterator that can be moved to point (forward and backward) to any
element in constant time.
@since version 1.0.0
@since version 1.0.0, simplified in version 2.0.9
*/
template <typename U>
template<typename U>
class iter_impl : public std::iterator<std::random_access_iterator_tag, U>
{
/// allow basic_json to access private members
@ -8240,12 +8241,12 @@ class basic_json
using difference_type = typename basic_json::difference_type;
/// defines a pointer to the type iterated over (value_type)
using pointer = typename std::conditional<std::is_const<U>::value,
typename basic_json::const_pointer,
typename basic_json::pointer>::type;
typename basic_json::const_pointer,
typename basic_json::pointer>::type;
/// defines a reference to the type iterated over (value_type)
using reference = typename std::conditional<std::is_const<U>::value,
typename basic_json::const_reference,
typename basic_json::reference>::type;
typename basic_json::const_reference,
typename basic_json::reference>::type;
/// the category of the iterator
using iterator_category = std::bidirectional_iterator_tag;
@ -8286,19 +8287,19 @@ class basic_json
}
/*
Use operator const_iterator instead of
const_iterator(const iterator& other) noexcept
to avoid two class definitions for iterator and const_iterator.
Use operator `const_iterator` instead of `const_iterator(const iterator&
other) noexcept` to avoid two class definitions for @ref iterator and
@ref const_iterator.
This function is only called if this class is an iterator.
If this class is a const_iterator this function is not called.
This function is only called if this class is an @ref iterator. If this
class is a @ref const_iterator this function is not called.
*/
operator const_iterator() const
{
const_iterator ret;
{
const_iterator ret;
if (m_object)
{
{
ret.m_object = m_object;
ret.m_it = m_it;
}