-
-
If value()==0
, all of item…
are discarded and no further action is taken.
+If this->value()==0
, all of item…
are discarded and no further action is taken.
-
Otherwise, what happens with each item
depends on its type:
@@ -5473,7 +5473,7 @@ load
If it is a function that takes a single argument of some type E &
, that function is called with the object of type E
currently associated with *this
. If no such object exists, a default-initialized object is associated with *this
and then passed to the function.
-
-
If it is a function that takes no arguments, than function is called to obtain an error object, which is associated with *this
.
+If it is a function that takes no arguments, that function is called to obtain an error object which is associated with *this
, except in the special case of a void
function, in which case it is invoked and no error object is obtained/loaded.
-
Otherwise, the item
itself is assumed to be an error object, which is associated with *this
.
diff --git a/leaf.hpp b/leaf.hpp
index 92a5d7a5..e32d2816 100644
--- a/leaf.hpp
+++ b/leaf.hpp
@@ -3,7 +3,7 @@
// LEAF single header distribution. Do not edit.
-// Generated on 01/08/2024 from https://github.com/boostorg/leaf/tree/668049c.
+// Generated on 01/09/2024 from https://github.com/boostorg/leaf/tree/031dfa0.
// Latest version of this file: https://raw.githubusercontent.com/boostorg/leaf/gh-pages/leaf.hpp.
// Copyright 2018-2023 Emil Dotchevski and Reverge Studios, Inc.
@@ -2262,7 +2262,7 @@ namespace leaf_detail
}
template
- inline void dynamic_accumulate( int err_id, F && f ) noexcept(OnError)
+ inline void dynamic_load_accumulate( int err_id, F && f ) noexcept(OnError)
{
if( OnError )
{
@@ -2310,9 +2310,9 @@ namespace leaf_detail
template
BOOST_LEAF_CONSTEXPR inline int load_slot( int err_id, E && e ) noexcept(OnError)
{
- static_assert(!std::is_pointer::value, "Error objects of pointer types are not allowed");
- static_assert(!std::is_same::type, error_id>::value, "Error objects of type error_id are not allowed");
using T = typename std::decay::type;
+ static_assert(!std::is_pointer::value, "Error objects of pointer types are not allowed");
+ static_assert(!std::is_same::value, "Error objects of type error_id are not allowed");
BOOST_LEAF_ASSERT((err_id&3)==1);
if( slot * p = tls::read_ptr>() )
{
@@ -2327,7 +2327,27 @@ namespace leaf_detail
}
template
- BOOST_LEAF_CONSTEXPR inline int accumulate_slot( int err_id, F && f ) noexcept(OnError)
+ BOOST_LEAF_CONSTEXPR inline int load_slot_deferred( int err_id, F && f ) noexcept(OnError)
+ {
+ using E = typename function_traits::return_type;
+ using T = typename std::decay::type;
+ static_assert(!std::is_pointer::value, "Error objects of pointer types are not allowed");
+ static_assert(!std::is_same::value, "Error objects of type error_id are not allowed");
+ BOOST_LEAF_ASSERT((err_id&3)==1);
+ if( slot * p = tls::read_ptr>() )
+ {
+ if( !OnError || !p->has_value(err_id) )
+ (void) p->load(err_id, std::forward(f)());
+ }
+#if BOOST_LEAF_CFG_CAPTURE
+ else
+ dynamic_load(err_id, std::forward(f)());
+#endif
+ return 0;
+ }
+
+ template
+ BOOST_LEAF_CONSTEXPR inline int load_slot_accumulate( int err_id, F && f ) noexcept(OnError)
{
static_assert(function_traits::arity==1, "Lambdas passed to accumulate must take a single e-type argument by reference");
using E = typename std::decay>::type;
@@ -2342,7 +2362,7 @@ namespace leaf_detail
}
#if BOOST_LEAF_CFG_CAPTURE
else
- dynamic_accumulate(err_id, std::forward(f));
+ dynamic_load_accumulate(err_id, std::forward(f));
#endif
return 0;
}
@@ -2376,7 +2396,7 @@ namespace leaf_detail
{
BOOST_LEAF_CONSTEXPR static int load_( int err_id, F && f ) noexcept
{
- return load_slot(err_id, std::forward(f)());
+ return load_slot_deferred(err_id, std::forward(f));
}
};
@@ -2385,7 +2405,7 @@ namespace leaf_detail
{
BOOST_LEAF_CONSTEXPR static int load_( int err_id, F && f ) noexcept
{
- return accumulate_slot(err_id, std::forward(f));
+ return load_slot_accumulate(err_id, std::forward(f));
}
};
}
@@ -4762,10 +4782,9 @@ namespace leaf_detail
}
};
- template
+ template ::return_type>
class deferred_item
{
- using E = decltype(std::declval()());
F f_;
public:
@@ -4777,7 +4796,25 @@ namespace leaf_detail
BOOST_LEAF_CONSTEXPR void trigger( int err_id ) noexcept
{
- (void) load_slot(err_id, f_());
+ (void) load_slot_deferred(err_id, f_);
+ }
+ };
+
+ template
+ class deferred_item
+ {
+ F f_;
+
+ public:
+
+ BOOST_LEAF_CONSTEXPR deferred_item( F && f ) noexcept:
+ f_(std::forward(f))
+ {
+ }
+
+ BOOST_LEAF_CONSTEXPR void trigger( int ) noexcept
+ {
+ f_();
}
};
@@ -4787,7 +4824,6 @@ namespace leaf_detail
template
class accumulating_item
{
- using E = A0;
F f_;
public:
@@ -4799,7 +4835,7 @@ namespace leaf_detail
BOOST_LEAF_CONSTEXPR void trigger( int err_id ) noexcept
{
- accumulate_slot(err_id, std::move(f_));
+ load_slot_accumulate(err_id, std::move(f_));
}
};
@@ -5182,7 +5218,7 @@ struct is_predicate>: std::true_type
// Expanded at line 16: #include
// Expanded at line 1490: #include
// Expanded at line 1362: #include
-// Expanded at line 4370: #include
+// Expanded at line 4390: #include
#include
#include
@@ -5902,7 +5938,7 @@ struct is_result_type>: std::true_type
// Expanded at line 16: #include
// Expanded at line 731: #include
-// Expanded at line 5174: #include
+// Expanded at line 5210: #include
#include
#include
#include
diff --git a/leaf.pdf b/leaf.pdf
index 15cdd8a6..9df52779 100644
Binary files a/leaf.pdf and b/leaf.pdf differ