Skip to content

Commit 5bc9ebb

Browse files
committed
allow exception propagation in optional and variant conversion
1 parent c3d6757 commit 5bc9ebb

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

include/boost/json/detail/value_to.hpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -824,16 +824,18 @@ using value_to_category = conversion_category<
824824

825825
// std::optional
826826
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
827-
template<class T>
828-
result<std::optional<T>>
827+
template< class T, class Ctx1, class Ctx2 >
828+
result< std::optional<T> >
829829
tag_invoke(
830-
try_value_to_tag<std::optional<T>>,
831-
value const& jv)
830+
try_value_to_tag< std::optional<T> >,
831+
value const& jv,
832+
Ctx1 const&,
833+
Ctx2 const& ctx)
832834
{
833835
if( jv.is_null() )
834836
return std::optional<T>();
835837
else
836-
return try_value_to<T>(jv);
838+
return try_value_to<T>(jv, ctx);
837839
}
838840

839841
inline
@@ -852,11 +854,13 @@ tag_invoke(
852854

853855
// std::variant
854856
#ifndef BOOST_NO_CXX17_HDR_VARIANT
855-
template<class... Ts>
857+
template< class... Ts, class Ctx1, class Ctx2 >
856858
result< std::variant<Ts...> >
857859
tag_invoke(
858860
try_value_to_tag< std::variant<Ts...> >,
859-
value const& jv)
861+
value const& jv,
862+
Ctx1 const&,
863+
Ctx2 const& ctx)
860864
{
861865
error_code ec;
862866
BOOST_JSON_FAIL(ec, error::exhausted_variants);
@@ -868,7 +872,7 @@ tag_invoke(
868872
return;
869873

870874
using T = std::variant_alternative_t<I.value, Variant>;
871-
auto attempt = try_value_to<T>(jv);
875+
auto attempt = try_value_to<T>(jv, ctx);
872876
if( attempt )
873877
res.emplace(std::in_place_index_t<I>(), std::move(*attempt));
874878
});

0 commit comments

Comments
 (0)