Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
2c23f0a3
Commit
2c23f0a3
authored
Dec 08, 2018
by
David Avedissian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes requested from code review.
parent
f665a923
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
34 deletions
+39
-34
iterator_traits.hpp
include/nlohmann/detail/iterators/iterator_traits.hpp
+20
-17
json.hpp
single_include/nlohmann/json.hpp
+19
-17
No files found.
include/nlohmann/detail/iterators/iterator_traits.hpp
View file @
2c23f0a3
...
@@ -3,16 +3,17 @@
...
@@ -3,16 +3,17 @@
#include <iterator> // random_access_iterator_tag
#include <iterator> // random_access_iterator_tag
#include <nlohmann/detail/meta/void_t.hpp>
#include <nlohmann/detail/meta/void_t.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp>
namespace
nlohmann
namespace
nlohmann
{
{
namespace
detail
namespace
detail
{
{
template
<
class
It
,
class
=
void
>
template
<
typename
It
,
typename
=
void
>
struct
_
iterator_types
{};
struct
iterator_types
{};
template
<
class
It
>
template
<
typename
It
>
struct
_
iterator_types
<
struct
iterator_types
<
It
,
It
,
void_t
<
typename
It
::
difference_type
,
typename
It
::
value_type
,
typename
It
::
pointer
,
void_t
<
typename
It
::
difference_type
,
typename
It
::
value_type
,
typename
It
::
pointer
,
typename
It
::
reference
,
typename
It
::
iterator_category
>>
{
typename
It
::
reference
,
typename
It
::
iterator_category
>>
{
...
@@ -23,25 +24,26 @@ struct _iterator_types<
...
@@ -23,25 +24,26 @@ struct _iterator_types<
using
iterator_category
=
typename
It
::
iterator_category
;
using
iterator_category
=
typename
It
::
iterator_category
;
};
};
template
<
class
Iter
>
// This is required as some compilers implement std::iterator_traits in a way that
struct
iterator_traits
:
_iterator_types
<
Iter
>
{};
// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341.
template
<
typename
T
,
typename
=
void
>
struct
iterator_traits
{
};
template
<
class
T
>
template
<
typename
T
>
struct
iterator_traits
<
T
*>
{
struct
iterator_traits
<
T
,
enable_if_t
<!
std
::
is_pointer
<
T
>::
value
>>
typedef
std
::
random_access_iterator_tag
iterator_category
;
:
iterator_types
<
T
>
typedef
T
value_type
;
{
typedef
ptrdiff_t
difference_type
;
typedef
T
*
pointer
;
typedef
T
&
reference
;
};
};
template
<
class
T
>
template
<
typename
T
>
struct
iterator_traits
<
const
T
*
>
{
struct
iterator_traits
<
T
*
,
enable_if_t
<
std
::
is_object
<
T
>::
value
>
>
{
typedef
std
::
random_access_iterator_tag
iterator_category
;
typedef
std
::
random_access_iterator_tag
iterator_category
;
typedef
T
value_type
;
typedef
T
value_type
;
typedef
ptrdiff_t
difference_type
;
typedef
ptrdiff_t
difference_type
;
typedef
const
T
*
pointer
;
typedef
T
*
pointer
;
typedef
const
T
&
reference
;
typedef
T
&
reference
;
};
};
}
}
}
}
\ No newline at end of file
single_include/nlohmann/json.hpp
View file @
2c23f0a3
...
@@ -344,16 +344,18 @@ template <typename ...Ts> using void_t = typename make_void<Ts...>::type;
...
@@ -344,16 +344,18 @@ template <typename ...Ts> using void_t = typename make_void<Ts...>::type;
}
// namespace detail
}
// namespace detail
}
// namespace nlohmann
}
// namespace nlohmann
// #include <nlohmann/detail/meta/cpp_future.hpp>
namespace
nlohmann
namespace
nlohmann
{
{
namespace
detail
namespace
detail
{
{
template
<
class
It
,
class
=
void
>
template
<
typename
It
,
typename
=
void
>
struct
_
iterator_types
{};
struct
iterator_types
{};
template
<
class
It
>
template
<
typename
It
>
struct
_
iterator_types
<
struct
iterator_types
<
It
,
It
,
void_t
<
typename
It
::
difference_type
,
typename
It
::
value_type
,
typename
It
::
pointer
,
void_t
<
typename
It
::
difference_type
,
typename
It
::
value_type
,
typename
It
::
pointer
,
typename
It
::
reference
,
typename
It
::
iterator_category
>>
typename
It
::
reference
,
typename
It
::
iterator_category
>>
...
@@ -365,27 +367,27 @@ struct _iterator_types <
...
@@ -365,27 +367,27 @@ struct _iterator_types <
using
iterator_category
=
typename
It
::
iterator_category
;
using
iterator_category
=
typename
It
::
iterator_category
;
};
};
template
<
class
Iter
>
// This is required due to https://github.com/nlohmann/json/issues/1341 - where some
struct
iterator_traits
:
_iterator_types
<
Iter
>
{};
// compilers implement std::iterator_traits in a way that doesn't work with SFINAE.
template
<
typename
T
,
typename
=
void
>
struct
iterator_traits
{
};
template
<
class
T
>
template
<
typename
T
>
struct
iterator_traits
<
T
*>
struct
iterator_traits
<
T
,
enable_if_t
<
!
std
::
is_pointer
<
T
>::
value
>>
:
iterator_types
<
T
>
{
{
typedef
std
::
random_access_iterator_tag
iterator_category
;
typedef
T
value_type
;
typedef
ptrdiff_t
difference_type
;
typedef
T
*
pointer
;
typedef
T
&
reference
;
};
};
template
<
class
T
>
template
<
typename
T
>
struct
iterator_traits
<
const
T
*
>
struct
iterator_traits
<
T
*
,
enable_if_t
<
std
::
is_object
<
T
>::
value
>
>
{
{
typedef
std
::
random_access_iterator_tag
iterator_category
;
typedef
std
::
random_access_iterator_tag
iterator_category
;
typedef
T
value_type
;
typedef
T
value_type
;
typedef
ptrdiff_t
difference_type
;
typedef
ptrdiff_t
difference_type
;
typedef
const
T
*
pointer
;
typedef
T
*
pointer
;
typedef
const
T
&
reference
;
typedef
T
&
reference
;
};
};
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment