Skip to content

Commit

Permalink
🏁 fix for #1168
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Jul 19, 2018
1 parent 7bfc406 commit 04372a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 4 additions & 5 deletions include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7637,11 +7637,10 @@ namespace std
@since version 1.0.0
*/
template<>
inline void swap(nlohmann::json& j1,
nlohmann::json& j2) noexcept(
is_nothrow_move_constructible<nlohmann::json>::value and
is_nothrow_move_assignable<nlohmann::json>::value
)
inline void swap<nlohmann::json>(nlohmann::json& j1, nlohmann::json& j2) noexcept(

This comment has been minimized.

Copy link
@theodelrieu

theodelrieu Jul 19, 2018

Contributor

I think it would be better to make it a partial specialization, to handle basic_json<...>

This comment has been minimized.

Copy link
@nlohmann

nlohmann Jul 19, 2018

Author Owner

How would that look like?

This comment has been minimized.

Copy link
@theodelrieu

theodelrieu Jul 19, 2018

Contributor
NLOHMANN_BASIC_JSON_TPL_DECLARATION
inline void swap<NLOHMANN_BASIC_JSON_TPL>(NLOHMANN_BASIC_JSON_TPL& j1, NLOHMANN_BASIC_JSON_TPL&j2);

Did not try it out though, so might fail miserably to compile

This comment has been minimized.

Copy link
@nlohmann

nlohmann Jul 19, 2018

Author Owner

I'll try.

This comment has been minimized.

Copy link
@nlohmann

nlohmann Jul 19, 2018

Author Owner

I tried

NLOHMANN_BASIC_JSON_TPL_DECLARATION
inline void swap<NLOHMANN_BASIC_JSON_TPL>(NLOHMANN_BASIC_JSON_TPL& j1, NLOHMANN_BASIC_JSON_TPL& j2) noexcept(
    is_nothrow_move_constructible<NLOHMANN_BASIC_JSON_TPL>::value and
    is_nothrow_move_assignable<NLOHMANN_BASIC_JSON_TPL>::value
)

and got

 error: function template partial specialization is not allowed
inline void swap<NLOHMANN_BASIC_JSON_TPL>(NLOHMANN_BASIC_JSON_TPL& j1, NLOHMANN_BASIC_JSON_TPL& j2) noexcept(
            ^   ~~~~~~~~~~~~~~~~~~~~~~~~~

This comment has been minimized.

Copy link
@theodelrieu

theodelrieu Jul 19, 2018

Contributor

I'll give it a try tomorrow (on phone)

This comment has been minimized.

Copy link
@nlohmann

nlohmann Jul 19, 2018

Author Owner

No worries!

This comment has been minimized.

Copy link
@theodelrieu

theodelrieu Jul 20, 2018

Contributor

Well, I forgot that function partial specialization is forbidden, nevermind!

is_nothrow_move_constructible<nlohmann::json>::value and
is_nothrow_move_assignable<nlohmann::json>::value
)
{
j1.swap(j2);
}
Expand Down
9 changes: 4 additions & 5 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18472,11 +18472,10 @@ namespace std
@since version 1.0.0
*/
template<>
inline void swap(nlohmann::json& j1,
nlohmann::json& j2) noexcept(
is_nothrow_move_constructible<nlohmann::json>::value and
is_nothrow_move_assignable<nlohmann::json>::value
)
inline void swap<nlohmann::json>(nlohmann::json& j1, nlohmann::json& j2) noexcept(
is_nothrow_move_constructible<nlohmann::json>::value and
is_nothrow_move_assignable<nlohmann::json>::value
)
{
j1.swap(j2);
}
Expand Down

0 comments on commit 04372a8

Please sign in to comment.