Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
e84195ab
Unverified
Commit
e84195ab
authored
Sep 05, 2018
by
Théo DELRIEU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor is_compatible_object_type
parent
b59c3367
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
32 deletions
+40
-32
include/nlohmann/detail/meta/type_traits.hpp
include/nlohmann/detail/meta/type_traits.hpp
+20
-16
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+20
-16
No files found.
include/nlohmann/detail/meta/type_traits.hpp
View file @
e84195ab
...
...
@@ -65,17 +65,31 @@ struct is_complete_type : std::false_type {};
template
<
typename
T
>
struct
is_complete_type
<
T
,
decltype
(
void
(
sizeof
(
T
)))
>
:
std
::
true_type
{};
template
<
bool
B
,
class
RealType
,
class
CompatibleObjectType
>
template
<
typename
BasicJsonType
,
typename
CompatibleObjectType
,
typename
=
void
>
struct
is_compatible_object_type_impl
:
std
::
false_type
{};
template
<
class
RealType
,
class
CompatibleObjectType
>
struct
is_compatible_object_type_impl
<
true
,
RealType
,
CompatibleObjectType
>
template
<
typename
BasicJsonType
,
typename
CompatibleObjectType
>
struct
is_compatible_object_type_impl
<
BasicJsonType
,
CompatibleObjectType
,
enable_if_t
<
is_detected
<
mapped_type_t
,
CompatibleObjectType
>::
value
and
is_detected
<
key_type_t
,
CompatibleObjectType
>::
value
>>
{
static
constexpr
auto
value
=
std
::
is_constructible
<
typename
RealType
::
key_type
,
typename
CompatibleObjectType
::
key_type
>::
value
and
std
::
is_constructible
<
typename
RealType
::
mapped_type
,
typename
CompatibleObjectType
::
mapped_type
>::
value
;
using
object_t
=
typename
BasicJsonType
::
object_t
;
// macOS's is_constructible does not play well with nonesuch...
static
constexpr
bool
value
=
std
::
is_constructible
<
typename
object_t
::
key_type
,
typename
CompatibleObjectType
::
key_type
>::
value
and
std
::
is_constructible
<
typename
object_t
::
mapped_type
,
typename
CompatibleObjectType
::
mapped_type
>::
value
;
};
template
<
typename
BasicJsonType
,
typename
CompatibleObjectType
>
struct
is_compatible_object_type
:
is_compatible_object_type_impl
<
BasicJsonType
,
CompatibleObjectType
>
{};
template
<
bool
B
,
class
RealType
,
class
CompatibleStringType
>
struct
is_compatible_string_type_impl
:
std
::
false_type
{};
...
...
@@ -87,16 +101,6 @@ struct is_compatible_string_type_impl<true, RealType, CompatibleStringType>
std
::
is_constructible
<
RealType
,
CompatibleStringType
>::
value
;
};
template
<
class
BasicJsonType
,
class
CompatibleObjectType
>
struct
is_compatible_object_type
{
static
auto
constexpr
value
=
is_compatible_object_type_impl
<
conjunction
<
negation
<
std
::
is_same
<
void
,
CompatibleObjectType
>>
,
is_detected
<
mapped_type_t
,
CompatibleObjectType
>
,
is_detected
<
key_type_t
,
CompatibleObjectType
>>::
value
,
typename
BasicJsonType
::
object_t
,
CompatibleObjectType
>::
value
;
};
template
<
class
BasicJsonType
,
class
CompatibleStringType
>
struct
is_compatible_string_type
{
...
...
single_include/nlohmann/json.hpp
View file @
e84195ab
...
...
@@ -445,17 +445,31 @@ struct is_complete_type : std::false_type {};
template
<
typename
T
>
struct
is_complete_type
<
T
,
decltype
(
void
(
sizeof
(
T
)))
>
:
std
::
true_type
{};
template
<
bool
B
,
class
RealType
,
class
CompatibleObjectType
>
template
<
typename
BasicJsonType
,
typename
CompatibleObjectType
,
typename
=
void
>
struct
is_compatible_object_type_impl
:
std
::
false_type
{};
template
<
class
RealType
,
class
CompatibleObjectType
>
struct
is_compatible_object_type_impl
<
true
,
RealType
,
CompatibleObjectType
>
template
<
typename
BasicJsonType
,
typename
CompatibleObjectType
>
struct
is_compatible_object_type_impl
<
BasicJsonType
,
CompatibleObjectType
,
enable_if_t
<
is_detected
<
mapped_type_t
,
CompatibleObjectType
>::
value
and
is_detected
<
key_type_t
,
CompatibleObjectType
>::
value
>>
{
static
constexpr
auto
value
=
std
::
is_constructible
<
typename
RealType
::
key_type
,
typename
CompatibleObjectType
::
key_type
>::
value
and
std
::
is_constructible
<
typename
RealType
::
mapped_type
,
typename
CompatibleObjectType
::
mapped_type
>::
value
;
using
object_t
=
typename
BasicJsonType
::
object_t
;
// macOS's is_constructible does not play well with nonesuch...
static
constexpr
bool
value
=
std
::
is_constructible
<
typename
object_t
::
key_type
,
typename
CompatibleObjectType
::
key_type
>::
value
and
std
::
is_constructible
<
typename
object_t
::
mapped_type
,
typename
CompatibleObjectType
::
mapped_type
>::
value
;
};
template
<
typename
BasicJsonType
,
typename
CompatibleObjectType
>
struct
is_compatible_object_type
:
is_compatible_object_type_impl
<
BasicJsonType
,
CompatibleObjectType
>
{};
template
<
bool
B
,
class
RealType
,
class
CompatibleStringType
>
struct
is_compatible_string_type_impl
:
std
::
false_type
{};
...
...
@@ -467,16 +481,6 @@ struct is_compatible_string_type_impl<true, RealType, CompatibleStringType>
std
::
is_constructible
<
RealType
,
CompatibleStringType
>::
value
;
};
template
<
class
BasicJsonType
,
class
CompatibleObjectType
>
struct
is_compatible_object_type
{
static
auto
constexpr
value
=
is_compatible_object_type_impl
<
conjunction
<
negation
<
std
::
is_same
<
void
,
CompatibleObjectType
>>
,
is_detected
<
mapped_type_t
,
CompatibleObjectType
>
,
is_detected
<
key_type_t
,
CompatibleObjectType
>>::
value
,
typename
BasicJsonType
::
object_t
,
CompatibleObjectType
>::
value
;
};
template
<
class
BasicJsonType
,
class
CompatibleStringType
>
struct
is_compatible_string_type
{
...
...
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