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
225c8f15
Commit
225c8f15
authored
Jun 06, 2020
by
Guillaume Racicot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable std::swap specialization in C++20 and added a friend swap function
parent
7444c7fa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
2 deletions
+76
-2
macro_scope.hpp
include/nlohmann/detail/macro_scope.hpp
+5
-1
json.hpp
include/nlohmann/json.hpp
+33
-0
json.hpp
single_include/nlohmann/json.hpp
+38
-1
No files found.
include/nlohmann/detail/macro_scope.hpp
View file @
225c8f15
...
@@ -20,7 +20,11 @@
...
@@ -20,7 +20,11 @@
#endif
#endif
// C++ language standard detection
// C++ language standard detection
#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
#define JSON_HAS_CPP_20
#define JSON_HAS_CPP_17
#define JSON_HAS_CPP_14
#elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
#define JSON_HAS_CPP_17
#define JSON_HAS_CPP_17
#define JSON_HAS_CPP_14
#define JSON_HAS_CPP_14
#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
...
...
include/nlohmann/json.hpp
View file @
225c8f15
...
@@ -5865,6 +5865,34 @@ class basic_json
...
@@ -5865,6 +5865,34 @@ class basic_json
/*!
/*!
@brief exchanges the values
@brief exchanges the values
Exchanges the contents of the JSON value from @a left with those of @a right. Does not
invoke any move, copy, or swap operations on individual elements. All
iterators and references remain valid. The past-the-end iterator is
invalidated. implemented as a friend function callable via ADL.
@param[in,out] left JSON value to exchange the contents with
@param[in,out] right JSON value to exchange the contents with
@complexity Constant.
@liveexample{The example below shows how JSON values can be swapped with
`swap()`.,swap__reference}
@since version 1.0.0
*/
friend
void
swap
(
reference
left
,
reference
right
)
noexcept
(
std
::
is_nothrow_move_constructible
<
value_t
>::
value
and
std
::
is_nothrow_move_assignable
<
value_t
>::
value
and
std
::
is_nothrow_move_constructible
<
json_value
>::
value
and
std
::
is_nothrow_move_assignable
<
json_value
>::
value
)
{
left
.
swap
(
right
);
}
/*!
@brief exchanges the values
Exchanges the contents of a JSON array with those of @a other. Does not
Exchanges the contents of a JSON array with those of @a other. Does not
invoke any move, copy, or swap operations on individual elements. All
invoke any move, copy, or swap operations on individual elements. All
iterators and references remain valid. The past-the-end iterator is
iterators and references remain valid. The past-the-end iterator is
...
@@ -8635,6 +8663,9 @@ struct less<::nlohmann::detail::value_t>
...
@@ -8635,6 +8663,9 @@ struct less<::nlohmann::detail::value_t>
}
}
};
};
// C++20 prohibit function specialization in the std namespace.
#ifndef JSON_HAS_CPP_20
/*!
/*!
@brief exchanges the values of two JSON objects
@brief exchanges the values of two JSON objects
...
@@ -8649,6 +8680,8 @@ inline void swap<nlohmann::json>(nlohmann::json& j1, nlohmann::json& j2) noexcep
...
@@ -8649,6 +8680,8 @@ inline void swap<nlohmann::json>(nlohmann::json& j1, nlohmann::json& j2) noexcep
j1
.
swap
(
j2
);
j1
.
swap
(
j2
);
}
}
#endif
}
// namespace std
}
// namespace std
/*!
/*!
...
...
single_include/nlohmann/json.hpp
View file @
225c8f15
...
@@ -2048,7 +2048,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP
...
@@ -2048,7 +2048,11 @@ JSON_HEDLEY_DIAGNOSTIC_POP
#endif
#endif
// C++ language standard detection
// C++ language standard detection
#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
#define JSON_HAS_CPP_20
#define JSON_HAS_CPP_17
#define JSON_HAS_CPP_14
#elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
#define JSON_HAS_CPP_17
#define JSON_HAS_CPP_17
#define JSON_HAS_CPP_14
#define JSON_HAS_CPP_14
#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
...
@@ -21628,6 +21632,34 @@ class basic_json
...
@@ -21628,6 +21632,34 @@ class basic_json
/*!
/*!
@brief exchanges the values
@brief exchanges the values
Exchanges the contents of the JSON value from @a left with those of @a right. Does not
invoke any move, copy, or swap operations on individual elements. All
iterators and references remain valid. The past-the-end iterator is
invalidated. implemented as a friend function callable via ADL.
@param[in,out] left JSON value to exchange the contents with
@param[in,out] right JSON value to exchange the contents with
@complexity Constant.
@liveexample{The example below shows how JSON values can be swapped with
`swap()`.,swap__reference}
@since version 1.0.0
*/
friend
void
swap
(
reference
left
,
reference
right
)
noexcept
(
std
::
is_nothrow_move_constructible
<
value_t
>::
value
and
std
::
is_nothrow_move_assignable
<
value_t
>::
value
and
std
::
is_nothrow_move_constructible
<
json_value
>::
value
and
std
::
is_nothrow_move_assignable
<
json_value
>::
value
)
{
left
.
swap
(
right
);
}
/*!
@brief exchanges the values
Exchanges the contents of a JSON array with those of @a other. Does not
Exchanges the contents of a JSON array with those of @a other. Does not
invoke any move, copy, or swap operations on individual elements. All
invoke any move, copy, or swap operations on individual elements. All
iterators and references remain valid. The past-the-end iterator is
iterators and references remain valid. The past-the-end iterator is
...
@@ -24398,6 +24430,9 @@ struct less<::nlohmann::detail::value_t>
...
@@ -24398,6 +24430,9 @@ struct less<::nlohmann::detail::value_t>
}
}
};
};
// C++20 prohibit function specialization in the std namespace.
#ifndef JSON_HAS_CPP_20
/*!
/*!
@brief exchanges the values of two JSON objects
@brief exchanges the values of two JSON objects
...
@@ -24412,6 +24447,8 @@ inline void swap<nlohmann::json>(nlohmann::json& j1, nlohmann::json& j2) noexcep
...
@@ -24412,6 +24447,8 @@ inline void swap<nlohmann::json>(nlohmann::json& j1, nlohmann::json& j2) noexcep
j1
.
swap
(
j2
);
j1
.
swap
(
j2
);
}
}
#endif
}
// namespace std
}
// namespace std
/*!
/*!
...
...
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