Skip to content

Commit

Permalink
Deploying to gh-pages from @ c973cd4 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
zajo committed Sep 28, 2024
1 parent 3bcf056 commit a36d4aa
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 31 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1923,7 +1923,7 @@ <h4 id="tutorial-async_eh">Transporting Errors Between Threads With Exception Ha
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Follow this link to see a complete example program: <a href="https://github.com/boostorg/leaf/blob/master/example/try_capture_all_eh.cpp?ts=4">try_capture_all_eh.cpp</a>.
Follow this link to see a complete example program: <a href="https://github.com/boostorg/leaf/blob/master/example/try_capture_all_exceptions.cpp?ts=4">try_capture_all_exceptions.cpp</a>.
</td>
</tr>
</table>
Expand Down Expand Up @@ -2494,7 +2494,7 @@ <h3 id="tutorial-on_error_in_c_callbacks">Using <code>error_monitor</code> to Re
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
When using Lua with C&#43;&#43;, we need to protect the Lua interpreter from exceptions that may be thrown from C&#43;&#43; functions installed as <code>lua_CFunction</code> callbacks. Here is the program from this section rewritten to use a C&#43;&#43; exception (instead of <code>leaf::result</code>) to safely communicate errors out of the <code>do_work</code> function: <a href="https://github.com/boostorg/leaf/blob/master/example/lua_callback_eh.cpp?ts=4">lua_callback_eh.cpp</a>.
When using Lua with C&#43;&#43;, we need to protect the Lua interpreter from exceptions that may be thrown from C&#43;&#43; functions installed as <code>lua_CFunction</code> callbacks. Here is the program from this section rewritten to use a C&#43;&#43; exception (instead of <code>leaf::result</code>) to safely communicate errors out of the <code>do_work</code> function: <a href="https://github.com/boostorg/leaf/blob/master/example/lua_callback_exceptions.cpp?ts=4">lua_callback_exceptions.cpp</a>.
</td>
</tr>
</table>
Expand Down
61 changes: 32 additions & 29 deletions leaf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define BOOST_LEAF_HPP_INCLUDED

// Boost LEAF single header distribution. Do not edit.
// Generated on Sep 15, 2024 from https://github.com/boostorg/leaf/tree/7bd20a5.
// Generated on Sep 28, 2024 from https://github.com/boostorg/leaf/tree/c973cd4.

// Latest published version of this file: https://raw.githubusercontent.com/boostorg/leaf/gh-pages/leaf.hpp.

Expand Down Expand Up @@ -891,7 +891,7 @@ struct BOOST_LEAF_SYMBOL_VISIBLE e_file_name

struct BOOST_LEAF_SYMBOL_VISIBLE e_file_name
{
constexpr static char const * const value = "<unavailable>";
char const * value = "<unavailable>";
BOOST_LEAF_CONSTEXPR explicit e_file_name( char const * ) { }
};

Expand Down Expand Up @@ -2427,30 +2427,30 @@ namespace detail

namespace detail
{
class leaf_category final: public std::error_category
class leaf_error_category final: public std::error_category
{
bool equivalent( int, std::error_condition const & ) const noexcept final override { return false; }
bool equivalent( std::error_code const &, int ) const noexcept final override { return false; }
char const * name() const noexcept final override { return "LEAF error"; }
std::string message( int ) const final override { return name(); }
public:
~leaf_category() noexcept final override { }
~leaf_error_category() noexcept final override { }
};

template <class=void>
struct get_error_category
struct get_leaf_error_category
{
static leaf_category cat;
static leaf_error_category cat;
};

template <class T>
leaf_category get_error_category<T>::cat;
leaf_error_category get_leaf_error_category<T>::cat;

inline int import_error_code( std::error_code const & ec ) noexcept
{
if( int err_id = ec.value() )
{
std::error_category const & cat = get_error_category<>::cat;
std::error_category const & cat = get_leaf_error_category<>::cat;
if( &ec.category() == &cat )
{
BOOST_LEAF_ASSERT((err_id&3) == 1);
Expand All @@ -2470,7 +2470,7 @@ namespace detail

inline bool is_error_id( std::error_code const & ec ) noexcept
{
bool res = (&ec.category() == &detail::get_error_category<>::cat);
bool res = (&ec.category() == &detail::get_leaf_error_category<>::cat);
BOOST_LEAF_ASSERT(!res || !ec.value() || ((ec.value()&3) == 1));
return res;
}
Expand Down Expand Up @@ -2504,21 +2504,22 @@ class BOOST_LEAF_SYMBOL_VISIBLE error_id
}

#if BOOST_LEAF_CFG_STD_SYSTEM_ERROR
error_id( std::error_code const & ec ) noexcept:
value_(detail::import_error_code(ec))
explicit error_id( std::error_code const & ec ) noexcept:
value_(detail::import_error_code(std::error_code(ec)))
{
BOOST_LEAF_ASSERT(!value_ || ((value_&3) == 1));
}

template <class Enum>
error_id( Enum e, typename std::enable_if<std::is_error_code_enum<Enum>::value, Enum>::type * = 0 ) noexcept:
error_id( Enum e, typename std::enable_if<std::is_error_code_enum<Enum>::value, int>::type = 0 ) noexcept:
value_(detail::import_error_code(e))
{
}

operator std::error_code() const noexcept
template <class T, typename std::enable_if<std::is_constructible<T, std::error_code>::value, int>::type = 0>
operator T() const noexcept
{
return std::error_code(value_, detail::get_error_category<>::cat);
return std::error_code(value_, detail::get_leaf_error_category<>::cat);
}
#endif

Expand Down Expand Up @@ -3624,7 +3625,7 @@ try_handle_all( TryBlock && try_block, H && ... h ) noexcept
else
{
detail::unload_result(&r);
error_id id = r.error();
error_id id(r.error());
ctx.deactivate();
using R = typename std::decay<decltype(std::declval<TryBlock>()().value())>::type;
return ctx.template handle_error<R>(std::move(id), std::forward<H>(h)...);
Expand All @@ -3644,12 +3645,12 @@ try_handle_some( TryBlock && try_block, H && ... h ) noexcept
else
{
detail::unload_result(&r);
error_id id = r.error();
error_id id(r.error());
ctx.deactivate();
using R = typename std::decay<decltype(std::declval<TryBlock>()())>::type;
auto rr = ctx.template handle_error<R>(std::move(id), std::forward<H>(h)..., [&r]()->R { return std::move(r); });
if( !rr )
ctx.unload(rr.error());
ctx.unload(error_id(rr.error()));
return rr;
}
}
Expand Down Expand Up @@ -3679,7 +3680,7 @@ namespace detail
{
auto r = std::forward<TryBlock>(try_block)();
unload_result(&r);
return std::move(r);
return r;
}
catch( std::exception & ex )
{
Expand Down Expand Up @@ -3720,7 +3721,7 @@ try_handle_all( TryBlock && try_block, H && ... h )
{
BOOST_LEAF_ASSERT(ctx.is_active());
detail::unload_result(&r);
error_id id = r.error();
error_id id(r.error());
ctx.deactivate();
using R = typename std::decay<decltype(std::declval<TryBlock>()().value())>::type;
return ctx.template handle_error<R>(std::move(id), std::forward<H>(h)...);
Expand All @@ -3740,7 +3741,7 @@ try_handle_some( TryBlock && try_block, H && ... h )
else if( ctx.is_active() )
{
detail::unload_result(&r);
error_id id = r.error();
error_id id(r.error());
ctx.deactivate();
using R = typename std::decay<decltype(std::declval<TryBlock>()())>::type;
auto rr = ctx.template handle_error<R>(std::move(id), std::forward<H>(h)...,
Expand All @@ -3749,12 +3750,12 @@ try_handle_some( TryBlock && try_block, H && ... h )
return std::move(r);
});
if( !rr )
ctx.unload(rr.error());
ctx.unload(error_id(rr.error()));
return rr;
}
else
{
ctx.unload(r.error());
ctx.unload(error_id(r.error()));
return r;
}
}
Expand Down Expand Up @@ -4544,7 +4545,7 @@ exception_to_result( F && f ) noexcept
} }

#endif // BOOST_LEAF_EXCEPTION_HPP_INCLUDED
// #include <boost/leaf/handle_errors.hpp> // Expanded at line 3098
// #include <boost/leaf/handle_errors.hpp> // Expanded at line 3099
// >>> #include <boost/leaf/on_error.hpp>
#ifndef BOOST_LEAF_ON_ERROR_HPP_INCLUDED
#define BOOST_LEAF_ON_ERROR_HPP_INCLUDED
Expand Down Expand Up @@ -4781,7 +4782,7 @@ on_error( Item && ... i )

// #line 8 "boost/leaf/pred.hpp"
// #include <boost/leaf/config.hpp> // Expanded at line 14
// #include <boost/leaf/handle_errors.hpp> // Expanded at line 3098
// #include <boost/leaf/handle_errors.hpp> // Expanded at line 3099

#if __cplusplus >= 201703L
# define BOOST_LEAF_MATCH_ARGS(et,v1,v) auto v1, auto... v
Expand Down Expand Up @@ -5077,7 +5078,7 @@ struct is_predicate<catch_<Ex...>>: std::true_type
// #include <boost/leaf/config.hpp> // Expanded at line 14
// #include <boost/leaf/detail/print.hpp> // Expanded at line 1582
// #include <boost/leaf/detail/capture_list.hpp> // Expanded at line 1576
// #include <boost/leaf/exception.hpp> // Expanded at line 4264
// #include <boost/leaf/exception.hpp> // Expanded at line 4265

#include <climits>
#include <functional>
Expand Down Expand Up @@ -5297,10 +5298,12 @@ class BOOST_LEAF_SYMBOL_VISIBLE BOOST_LEAF_ATTRIBUTE_NODISCARD result
}
}

operator error_id() noexcept
operator error_id() const noexcept
{
result_discriminant const what = r_.what_;
return what.kind() == result_discriminant::val? error_id() : what.get_error_id();
return what.kind() == result_discriminant::val?
error_id() :
what.get_error_id();
}
};

Expand Down Expand Up @@ -5802,8 +5805,8 @@ struct is_result_type<result<T>>: std::true_type
#if __cplusplus >= 201703L

// #include <boost/leaf/config.hpp> // Expanded at line 14
// #include <boost/leaf/handle_errors.hpp> // Expanded at line 3098
// #include <boost/leaf/result.hpp> // Expanded at line 5073
// #include <boost/leaf/handle_errors.hpp> // Expanded at line 3099
// #include <boost/leaf/result.hpp> // Expanded at line 5074
#include <variant>
#include <optional>
#include <tuple>
Expand Down
Binary file modified leaf.pdf
Binary file not shown.

0 comments on commit a36d4aa

Please sign in to comment.