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
9b401972
Commit
9b401972
authored
Nov 17, 2016
by
Théo Delrieu
Committed by
Théo DELRIEU
Jan 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a macro for has_xxx types
parent
e2dbe7a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
56 deletions
+20
-56
json.hpp
src/json.hpp
+20
-56
No files found.
src/json.hpp
View file @
9b401972
...
@@ -140,6 +140,7 @@ template <class B1> struct conjunction<B1> : B1 {};
...
@@ -140,6 +140,7 @@ template <class B1> struct conjunction<B1> : B1 {};
template
<
class
B1
,
class
...
Bn
>
template
<
class
B1
,
class
...
Bn
>
struct
conjunction
<
B1
,
Bn
...
>
struct
conjunction
<
B1
,
Bn
...
>
:
conditional_t
<
bool
(
B1
::
value
),
conjunction
<
Bn
...
>
,
B1
>
{};
:
conditional_t
<
bool
(
B1
::
value
),
conjunction
<
Bn
...
>
,
B1
>
{};
template
<
class
B
>
struct
negation
:
std
::
integral_constant
<
bool
,
!
B
::
value
>
{};
template
<
class
B
>
struct
negation
:
std
::
integral_constant
<
bool
,
!
B
::
value
>
{};
template
<
class
...
>
struct
disjunction
:
std
::
false_type
{};
template
<
class
...
>
struct
disjunction
:
std
::
false_type
{};
template
<
class
B1
>
struct
disjunction
<
B1
>
:
B1
{};
template
<
class
B1
>
struct
disjunction
<
B1
>
:
B1
{};
...
@@ -149,68 +150,31 @@ struct disjunction<B1, Bn...>
...
@@ -149,68 +150,31 @@ struct disjunction<B1, Bn...>
/*!
/*!
@brief Helper to determine whether there's a key_type for T.
@brief Helper to determine whether there's a key_type for T.
Thus helper is used to tell associative containers apart from other containers
Thus helper is used to tell associative containers apart from other containers
such as sequence containers. For instance, `std::map` passes the test as it
such as sequence containers. For instance, `std::map` passes the test as it
contains a `mapped_type`, whereas `std::vector` fails the test.
contains a `mapped_type`, whereas `std::vector` fails the test.
@sa http://stackoverflow.com/a/7728728/266378
@sa http://stackoverflow.com/a/7728728/266378
@since version 1.0.0, overworked in version 2.0.6
@since version 1.0.0, overworked in version 2.0.6
*/
*/
template
<
typename
T
>
#define NLOHMANN_JSON_HAS_HELPER(type) \
struct
has_mapped_type
template <typename T> struct has_##type { \
{
private: \
private
:
template <typename U, typename = typename U::type> \
template
<
typename
U
,
typename
=
typename
U
::
mapped_type
>
static int detect(U &&); \
static
int
detect
(
U
&&
);
\
static void detect(...); \
static
void
detect
(...);
\
public
:
public: \
static
constexpr
bool
value
=
static constexpr bool value = \
std
::
is_integral
<
decltype
(
detect
(
std
::
declval
<
T
>
()))
>::
value
;
std::is_integral<decltype(detect(std::declval<T>()))>::value; \
};
};
template
<
template
<
typename
...
>
class
T
>
NLOHMANN_JSON_HAS_HELPER
(
mapped_type
)
struct
wrapper
{};
NLOHMANN_JSON_HAS_HELPER
(
key_type
)
NLOHMANN_JSON_HAS_HELPER
(
value_type
)
template
<
typename
T
>
NLOHMANN_JSON_HAS_HELPER
(
iterator
)
struct
has_key_type
{
#undef NLOHMANN_JSON_HAS_HELPER
private
:
template
<
typename
U
,
typename
=
typename
U
::
key_type
>
static
int
detect
(
U
&&
);
static
void
detect
(...);
public
:
static
constexpr
bool
value
=
std
::
is_integral
<
decltype
(
detect
(
std
::
declval
<
T
>
()))
>::
value
;
};
template
<
typename
T
>
struct
has_value_type
{
private
:
template
<
typename
U
,
typename
=
typename
U
::
value_type
>
static
int
detect
(
U
&&
);
static
void
detect
(...);
public
:
static
constexpr
bool
value
=
std
::
is_integral
<
decltype
(
detect
(
std
::
declval
<
T
>
()))
>::
value
;
};
template
<
typename
T
>
struct
has_iterator
{
private
:
template
<
typename
U
,
typename
=
typename
U
::
iterator
>
static
int
detect
(
U
&&
);
static
void
detect
(...);
public
:
static
constexpr
bool
value
=
std
::
is_integral
<
decltype
(
detect
(
std
::
declval
<
T
>
()))
>::
value
;
};
template
<
bool
B
,
class
RealType
,
class
CompatibleObjectType
>
template
<
bool
B
,
class
RealType
,
class
CompatibleObjectType
>
struct
is_compatible_object_type_impl
:
std
::
false_type
{};
struct
is_compatible_object_type_impl
:
std
::
false_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