| 1 | // __ _____ _____ _____ |
| 2 | // __| | __| | | | JSON for Modern C++ |
| 3 | // | | |__ | | | | | | version 3.11.3 |
| 4 | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
| 5 | // |
| 6 | // SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me> |
| 7 | // SPDX-License-Identifier: MIT |
| 8 | |
| 9 | #pragma once |
| 10 | |
| 11 | #include <iterator> // random_access_iterator_tag |
| 12 | |
| 13 | #include <nlohmann/detail/abi_macros.hpp> |
| 14 | #include <nlohmann/detail/meta/void_t.hpp> |
| 15 | #include <nlohmann/detail/meta/cpp_future.hpp> |
| 16 | |
| 17 | NLOHMANN_JSON_NAMESPACE_BEGIN |
| 18 | namespace detail |
| 19 | { |
| 20 | |
| 21 | template<typename It, typename = void> |
| 22 | struct iterator_types {}; |
| 23 | |
| 24 | template<typename It> |
| 25 | struct iterator_types < |
| 26 | It, |
| 27 | void_t<typename It::difference_type, typename It::value_type, typename It::pointer, |
| 28 | typename It::reference, typename It::iterator_category >> |
| 29 | { |
| 30 | using difference_type = typename It::difference_type; |
| 31 | using value_type = typename It::value_type; |
| 32 | using pointer = typename It::pointer; |
| 33 | using reference = typename It::reference; |
| 34 | using iterator_category = typename It::iterator_category; |
| 35 | }; |
| 36 | |
| 37 | // This is required as some compilers implement std::iterator_traits in a way that |
| 38 | // doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. |
| 39 | template<typename T, typename = void> |
| 40 | struct iterator_traits |
| 41 | { |
| 42 | }; |
| 43 | |
| 44 | template<typename T> |
| 45 | struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >> |
| 46 | : iterator_types<T> |
| 47 | { |
| 48 | }; |
| 49 | |
| 50 | template<typename T> |
| 51 | struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>> |
| 52 | { |
| 53 | using iterator_category = std::random_access_iterator_tag; |
| 54 | using value_type = T; |
| 55 | using difference_type = ptrdiff_t; |
| 56 | using pointer = T*; |
| 57 | using reference = T&; |
| 58 | }; |
| 59 | |
| 60 | } // namespace detail |
| 61 | NLOHMANN_JSON_NAMESPACE_END |
| 62 | |