2018-11-07 19:39:25 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <iterator> // random_access_iterator_tag
|
|
|
|
|
|
|
|
#include <nlohmann/detail/meta/void_t.hpp>
|
2018-12-08 16:46:33 +01:00
|
|
|
#include <nlohmann/detail/meta/cpp_future.hpp>
|
2018-11-07 19:39:25 +01:00
|
|
|
|
|
|
|
namespace nlohmann
|
|
|
|
{
|
|
|
|
namespace detail
|
|
|
|
{
|
2018-12-08 16:46:33 +01:00
|
|
|
template <typename It, typename = void>
|
|
|
|
struct iterator_types {};
|
2018-11-07 19:39:25 +01:00
|
|
|
|
2018-12-08 16:46:33 +01:00
|
|
|
template <typename It>
|
2019-03-28 14:23:26 +01:00
|
|
|
struct iterator_types <
|
2018-11-07 19:39:25 +01:00
|
|
|
It,
|
|
|
|
void_t<typename It::difference_type, typename It::value_type, typename It::pointer,
|
2019-03-28 14:23:26 +01:00
|
|
|
typename It::reference, typename It::iterator_category >>
|
|
|
|
{
|
|
|
|
using difference_type = typename It::difference_type;
|
|
|
|
using value_type = typename It::value_type;
|
|
|
|
using pointer = typename It::pointer;
|
|
|
|
using reference = typename It::reference;
|
|
|
|
using iterator_category = typename It::iterator_category;
|
2018-11-07 19:39:25 +01:00
|
|
|
};
|
|
|
|
|
2018-12-08 16:46:33 +01:00
|
|
|
// This is required as some compilers implement std::iterator_traits in a way that
|
|
|
|
// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341.
|
|
|
|
template <typename T, typename = void>
|
|
|
|
struct iterator_traits
|
|
|
|
{
|
|
|
|
};
|
2018-11-07 19:39:25 +01:00
|
|
|
|
2018-12-08 16:46:33 +01:00
|
|
|
template <typename T>
|
2019-03-28 14:23:26 +01:00
|
|
|
struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
|
|
|
|
: iterator_types<T>
|
2018-12-08 16:46:33 +01:00
|
|
|
{
|
2018-11-07 19:39:25 +01:00
|
|
|
};
|
|
|
|
|
2018-12-08 16:46:33 +01:00
|
|
|
template <typename T>
|
2019-03-28 14:23:26 +01:00
|
|
|
struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>
|
|
|
|
{
|
|
|
|
using iterator_category = std::random_access_iterator_tag;
|
|
|
|
using value_type = T;
|
|
|
|
using difference_type = ptrdiff_t;
|
|
|
|
using pointer = T*;
|
|
|
|
using reference = T&;
|
2018-11-07 19:39:25 +01:00
|
|
|
};
|
2019-03-15 14:55:13 +01:00
|
|
|
} // namespace detail
|
|
|
|
} // namespace nlohmann
|