@@ -525,55 +525,6 @@ initialize_variant( V&& v, mp11::mp_int<1> )
525525}
526526#endif // BOOST_NO_CXX17_HDR_VARIANT
527527
528- struct locally_prohibit_exceptions
529- {};
530-
531- template < class Ctx >
532- Ctx const &
533- make_locally_nonthrowing_context (Ctx const & ctx) noexcept
534- {
535- return ctx;
536- }
537-
538- template < class ... Ctxes >
539- std::tuple<Ctxes...> const &
540- make_locally_nonthrowing_context (std::tuple<Ctxes...> const & ctx) noexcept
541- {
542- return ctx;
543- }
544-
545- template < class ... Ctxes >
546- std::tuple<locally_prohibit_exceptions, allow_exceptions, Ctxes...>
547- make_locally_nonthrowing_context (std::tuple<allow_exceptions, Ctxes...> const & ctx)
548- noexcept
549- {
550- return std::tuple_cat (std::make_tuple ( locally_prohibit_exceptions () ), ctx);
551- }
552-
553- template < class Ctx >
554- Ctx const &
555- remove_local_exception_prohibition (Ctx const & ctx) noexcept
556- {
557- return ctx;
558- }
559-
560- template < class T , class ... Ts, std::size_t ... Is>
561- std::tuple<Ts...>
562- remove_local_exception_prohibition_helper (
563- std::tuple<T, Ts...> const & tup,
564- mp11::index_sequence<Is...>) noexcept
565- {
566- return std::tuple<Ts...>( std::get<Is + 1 >(tup)... );
567- }
568-
569- template < class ... Ctxes >
570- std::tuple<Ctxes...>
571- remove_local_exception_prohibition (
572- std::tuple<locally_prohibit_exceptions, Ctxes...> const & ctx) noexcept
573- {
574- return remove_local_exception_prohibition_helper (
575- ctx, mp11::index_sequence_for<Ctxes...>() );
576- }
577528
578529template < class T , class Ctx >
579530struct alternative_converter
@@ -588,9 +539,8 @@ struct alternative_converter
588539 if ( res )
589540 return ;
590541
591- auto && local_ctx = make_locally_nonthrowing_context (ctx);
592542 using V = mp11::mp_at<T, I>;
593- auto attempt = try_value_to<V>(jv, local_ctx );
543+ auto attempt = try_value_to<V>(jv, ctx );
594544 if ( attempt )
595545 {
596546 using cat = variant_construction_category<T, V, I>;
@@ -709,28 +659,6 @@ value_to_impl(
709659 return std::move (*res);
710660}
711661
712- template < class Ctx >
713- std::tuple<allow_exceptions, Ctx>
714- make_throwing_context (Ctx const & ctx)
715- {
716- return std::tuple<allow_exceptions, Ctx>(allow_exceptions (), ctx);
717- }
718-
719- template < class ... Ctxes >
720- std::tuple<allow_exceptions, Ctxes...>
721- make_throwing_context (std::tuple<Ctxes...> const & ctx)
722- {
723- return std::tuple_cat (std::make_tuple ( allow_exceptions () ), ctx);
724- }
725-
726- template < class ... Ctxes >
727- std::tuple<allow_exceptions, Ctxes...> const &
728- make_throwing_context (std::tuple<allow_exceptions, Ctxes...> const & ctx)
729- noexcept
730- {
731- return ctx;
732- }
733-
734662template <
735663 class T ,
736664 class Ctx ,
@@ -746,11 +674,7 @@ value_to_impl(
746674 value const & jv,
747675 Ctx const & ctx )
748676{
749- auto res = tag_invoke (
750- try_value_to_tag<T>(),
751- jv,
752- Sup::get (ctx),
753- make_throwing_context (ctx));
677+ auto res = tag_invoke (try_value_to_tag<T>(), jv, Sup::get (ctx), ctx);
754678 if ( res.has_error () )
755679 throw_system_error ( res.error () );
756680 return std::move (*res);
@@ -809,36 +733,17 @@ value_to_impl(
809733// ----------------------------------------------------------
810734// User-provided conversions; nonthrowing -> throwing
811735
812- template < class Ctx >
813- struct does_allow_exceptions : std::false_type
814- { };
815-
816- template < class ... Ctxes >
817- struct does_allow_exceptions < std::tuple<allow_exceptions, Ctxes...> >
818- : std::true_type
819- { };
820-
821- template < class T , class ... Args >
822- system::result<T>
823- wrap_conversion_exceptions ( std::true_type, value_to_tag<T>, Args&& ... args )
824- {
825- return {
826- boost::system::in_place_value,
827- tag_invoke ( value_to_tag<T>(), static_cast <Args&&>(args)... )};
828- }
829-
830736template < class T , class ... Args >
831737system::result<T>
832- wrap_conversion_exceptions ( std::false_type, value_to_tag<T>, Args&& ... args )
738+ wrap_conversion_exceptions ( value_to_tag<T>, Args&& ... args )
833739{
834740#ifndef BOOST_NO_EXCEPTIONS
835741 try
836742 {
837743#endif
838- return wrap_conversion_exceptions (
839- std::true_type (),
840- value_to_tag<T>(),
841- static_cast <Args&&>(args)... );
744+ return {
745+ boost::system::in_place_value,
746+ tag_invoke ( value_to_tag<T>(), static_cast <Args&&>(args)... )};
842747#ifndef BOOST_NO_EXCEPTIONS
843748 }
844749 catch ( std::bad_alloc const &)
@@ -865,8 +770,7 @@ mp11::mp_if_c<
865770value_to_impl (
866771 user_conversion_tag, try_value_to_tag<T>, value const & jv, Ctx const & )
867772{
868- return wrap_conversion_exceptions (
869- does_allow_exceptions<Ctx>(), value_to_tag<T>(), jv);
773+ return wrap_conversion_exceptions (value_to_tag<T>(), jv);
870774}
871775
872776template <
@@ -886,8 +790,7 @@ value_to_impl(
886790 value const & jv,
887791 Ctx const & ctx )
888792{
889- return wrap_conversion_exceptions (
890- does_allow_exceptions<Ctx>(), value_to_tag<T>(), jv, Sup::get (ctx) );
793+ return wrap_conversion_exceptions ( value_to_tag<T>(), jv, Sup::get (ctx) );
891794}
892795
893796template <
@@ -908,11 +811,7 @@ value_to_impl(
908811 Ctx const & ctx )
909812{
910813 return wrap_conversion_exceptions (
911- does_allow_exceptions<Ctx>(),
912- value_to_tag<T>(),
913- jv,
914- Sup::get (ctx),
915- remove_local_exception_prohibition (ctx) );
814+ value_to_tag<T>(), jv, Sup::get (ctx), ctx);
916815}
917816
918817// no suitable conversion implementation
@@ -930,8 +829,7 @@ template< class Impl, class T, class Ctx >
930829T
931830value_to_impl ( Impl impl, value_to_tag<T>, value const & jv, Ctx const & ctx )
932831{
933- return value_to_impl (
934- impl, try_value_to_tag<T>(), jv, make_throwing_context (ctx) ).value ();
832+ return value_to_impl (impl, try_value_to_tag<T>(), jv, ctx).value ();
935833}
936834
937835template < class Ctx , class T >
0 commit comments