Skip to content

Commit

Permalink
🔨 approach to un-break the changes for #462
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Aug 16, 2017
1 parent 22b5969 commit aba8b58
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13182,6 +13182,15 @@ class basic_json
return binary_reader(i).parse_cbor(strict);
}

/*!
@copydoc from_cbor(detail::input_adapter, const bool)
*/
template<typename A1, typename A2,
detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
static basic_json from_cbor(A1&& a1, A2&& a2, const bool strict = true)
{
return binary_reader(detail::input_adapter(std::forward<A1>(a1), std::forward<A2>(a2))).parse_cbor(strict);
}

/*!
@brief create a JSON value from an input in MessagePack format
Expand Down Expand Up @@ -13260,6 +13269,16 @@ class basic_json
return binary_reader(i).parse_msgpack(strict);
}

/*!
@copydoc from_msgpack(detail::input_adapter, const bool)
*/
template<typename A1, typename A2,
detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
static basic_json from_msgpack(A1&& a1, A2&& a2, const bool strict = true)
{
return binary_reader(detail::input_adapter(std::forward<A1>(a1), std::forward<A2>(a2))).parse_msgpack(strict);
}

/// @}

//////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion test/src/unit-cbor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ TEST_CASE("single CBOR roundtrip")

// check with different start index
packed.insert(packed.begin(), 5, 0xff);
CHECK(j1 == json::from_cbor({packed.begin() + 5, packed.end()}));
CHECK(j1 == json::from_cbor(packed.begin() + 5, packed.end()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/src/unit-msgpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ TEST_CASE("single MessagePack roundtrip")

// check with different start index
packed.insert(packed.begin(), 5, 0xff);
CHECK(j1 == json::from_msgpack({packed.begin() + 5, packed.end()}));
CHECK(j1 == json::from_msgpack(packed.begin() + 5, packed.end()));
}
}

Expand Down

0 comments on commit aba8b58

Please sign in to comment.