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
29f72966
Unverified
Commit
29f72966
authored
Sep 05, 2018
by
Théo DELRIEU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor is_compatible_type, remove conjunction & co
parent
77967e65
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
60 deletions
+24
-60
include/nlohmann/detail/meta/cpp_future.hpp
include/nlohmann/detail/meta/cpp_future.hpp
+0
-20
include/nlohmann/detail/meta/type_traits.hpp
include/nlohmann/detail/meta/type_traits.hpp
+12
-10
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+12
-30
No files found.
include/nlohmann/detail/meta/cpp_future.hpp
View file @
29f72966
...
@@ -46,26 +46,6 @@ template<> struct make_index_sequence<1> : index_sequence<0> {};
...
@@ -46,26 +46,6 @@ template<> struct make_index_sequence<1> : index_sequence<0> {};
template
<
typename
...
Ts
>
template
<
typename
...
Ts
>
using
index_sequence_for
=
make_index_sequence
<
sizeof
...(
Ts
)
>
;
using
index_sequence_for
=
make_index_sequence
<
sizeof
...(
Ts
)
>
;
/*
Implementation of two C++17 constructs: conjunction, negation. This is needed
to avoid evaluating all the traits in a condition
For example: not std::is_same<void, T>::value and has_value_type<T>::value
will not compile when T = void (on MSVC at least). Whereas
conjunction<negation<std::is_same<void, T>>, has_value_type<T>>::value will
stop evaluating if negation<...>::value == false
Please note that those constructs must be used with caution, since symbols can
become very long quickly (which can slow down compilation and cause MSVC
internal compiler errors). Only use it when you have to (see example ahead).
*/
template
<
class
...
>
struct
conjunction
:
std
::
true_type
{};
template
<
class
B1
>
struct
conjunction
<
B1
>
:
B1
{};
template
<
class
B1
,
class
...
Bn
>
struct
conjunction
<
B1
,
Bn
...
>
:
std
::
conditional
<
bool
(
B1
::
value
),
conjunction
<
Bn
...
>
,
B1
>::
type
{};
template
<
class
B
>
struct
negation
:
std
::
integral_constant
<
bool
,
not
B
::
value
>
{};
// dispatch utility (taken from ranges-v3)
// dispatch utility (taken from ranges-v3)
template
<
unsigned
N
>
struct
priority_tag
:
priority_tag
<
N
-
1
>
{};
template
<
unsigned
N
>
struct
priority_tag
:
priority_tag
<
N
-
1
>
{};
template
<
>
struct
priority_tag
<
0
>
{};
template
<
>
struct
priority_tag
<
0
>
{};
...
...
include/nlohmann/detail/meta/type_traits.hpp
View file @
29f72966
...
@@ -198,21 +198,23 @@ struct has_to_json
...
@@ -198,21 +198,23 @@ struct has_to_json
T
>::
value
;
T
>::
value
;
};
};
template
<
typename
BasicJsonType
,
typename
CompatibleCompleteType
>
template
<
typename
BasicJsonType
,
typename
CompatibleType
,
typename
=
void
>
struct
is_compatible_complete_type
struct
is_compatible_type_impl
:
std
::
false_type
{};
template
<
typename
BasicJsonType
,
typename
CompatibleType
>
struct
is_compatible_type_impl
<
BasicJsonType
,
CompatibleType
,
enable_if_t
<
is_complete_type
<
CompatibleType
>::
value
>>
{
{
static
constexpr
bool
value
=
static
constexpr
bool
value
=
not
std
::
is_base_of
<
std
::
istream
,
Compatible
Complete
Type
>::
value
and
not
std
::
is_base_of
<
std
::
istream
,
CompatibleType
>::
value
and
not
is_basic_json
<
Compatible
Complete
Type
>::
value
and
not
is_basic_json
<
CompatibleType
>::
value
and
not
is_basic_json_nested_type
<
BasicJsonType
,
Compatible
Complete
Type
>::
value
and
not
is_basic_json_nested_type
<
BasicJsonType
,
CompatibleType
>::
value
and
has_to_json
<
BasicJsonType
,
Compatible
Complete
Type
>::
value
;
has_to_json
<
BasicJsonType
,
CompatibleType
>::
value
;
};
};
template
<
typename
BasicJsonType
,
typename
CompatibleType
>
template
<
typename
BasicJsonType
,
typename
CompatibleType
>
struct
is_compatible_type
struct
is_compatible_type
:
conjunction
<
is_complete_type
<
CompatibleType
>
,
:
is_compatible_type_impl
<
BasicJsonType
,
CompatibleType
>
{};
is_compatible_complete_type
<
BasicJsonType
,
CompatibleType
>>
{
};
}
}
}
}
single_include/nlohmann/json.hpp
View file @
29f72966
...
@@ -267,26 +267,6 @@ template<> struct make_index_sequence<1> : index_sequence<0> {};
...
@@ -267,26 +267,6 @@ template<> struct make_index_sequence<1> : index_sequence<0> {};
template
<
typename
...
Ts
>
template
<
typename
...
Ts
>
using
index_sequence_for
=
make_index_sequence
<
sizeof
...(
Ts
)
>
;
using
index_sequence_for
=
make_index_sequence
<
sizeof
...(
Ts
)
>
;
/*
Implementation of two C++17 constructs: conjunction, negation. This is needed
to avoid evaluating all the traits in a condition
For example: not std::is_same<void, T>::value and has_value_type<T>::value
will not compile when T = void (on MSVC at least). Whereas
conjunction<negation<std::is_same<void, T>>, has_value_type<T>>::value will
stop evaluating if negation<...>::value == false
Please note that those constructs must be used with caution, since symbols can
become very long quickly (which can slow down compilation and cause MSVC
internal compiler errors). Only use it when you have to (see example ahead).
*/
template
<
class
...
>
struct
conjunction
:
std
::
true_type
{};
template
<
class
B1
>
struct
conjunction
<
B1
>
:
B1
{};
template
<
class
B1
,
class
...
Bn
>
struct
conjunction
<
B1
,
Bn
...
>
:
std
::
conditional
<
bool
(
B1
::
value
),
conjunction
<
Bn
...
>
,
B1
>::
type
{};
template
<
class
B
>
struct
negation
:
std
::
integral_constant
<
bool
,
not
B
::
value
>
{};
// dispatch utility (taken from ranges-v3)
// dispatch utility (taken from ranges-v3)
template
<
unsigned
N
>
struct
priority_tag
:
priority_tag
<
N
-
1
>
{};
template
<
unsigned
N
>
struct
priority_tag
:
priority_tag
<
N
-
1
>
{};
template
<
>
struct
priority_tag
<
0
>
{};
template
<
>
struct
priority_tag
<
0
>
{};
...
@@ -578,22 +558,24 @@ struct has_to_json
...
@@ -578,22 +558,24 @@ struct has_to_json
T
>::
value
;
T
>::
value
;
};
};
template
<
typename
BasicJsonType
,
typename
CompatibleCompleteType
>
template
<
typename
BasicJsonType
,
typename
CompatibleType
,
typename
=
void
>
struct
is_compatible_complete_type
struct
is_compatible_type_impl
:
std
::
false_type
{};
template
<
typename
BasicJsonType
,
typename
CompatibleType
>
struct
is_compatible_type_impl
<
BasicJsonType
,
CompatibleType
,
enable_if_t
<
is_complete_type
<
CompatibleType
>::
value
>>
{
{
static
constexpr
bool
value
=
static
constexpr
bool
value
=
not
std
::
is_base_of
<
std
::
istream
,
Compatible
Complete
Type
>::
value
and
not
std
::
is_base_of
<
std
::
istream
,
CompatibleType
>::
value
and
not
is_basic_json
<
Compatible
Complete
Type
>::
value
and
not
is_basic_json
<
CompatibleType
>::
value
and
not
is_basic_json_nested_type
<
BasicJsonType
,
Compatible
Complete
Type
>::
value
and
not
is_basic_json_nested_type
<
BasicJsonType
,
CompatibleType
>::
value
and
has_to_json
<
BasicJsonType
,
Compatible
Complete
Type
>::
value
;
has_to_json
<
BasicJsonType
,
CompatibleType
>::
value
;
};
};
template
<
typename
BasicJsonType
,
typename
CompatibleType
>
template
<
typename
BasicJsonType
,
typename
CompatibleType
>
struct
is_compatible_type
struct
is_compatible_type
:
conjunction
<
is_complete_type
<
CompatibleType
>
,
:
is_compatible_type_impl
<
BasicJsonType
,
CompatibleType
>
{};
is_compatible_complete_type
<
BasicJsonType
,
CompatibleType
>>
{
};
}
}
}
}
...
...
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