Skip to content

Commit

Permalink
Merged scope_check into scope_exit.
Browse files Browse the repository at this point in the history
As suggested by Peter Dimov on boost-dev ML, scope_check functionality
is merged into scope_exit. Thus scope_exit now has an optional condition
function object, which by default always returns true. If a custom
function object is specified, scope_exit works equivalently to the
previous scope_check, i.e. calls the condition function object to check
whether the action function object needs to be called.
  • Loading branch information
Lastique committed Oct 14, 2023
1 parent f44ada4 commit 04ab51c
Show file tree
Hide file tree
Showing 8 changed files with 705 additions and 962 deletions.
512 changes: 0 additions & 512 deletions include/boost/scope/scope_check.hpp

This file was deleted.

422 changes: 365 additions & 57 deletions include/boost/scope/scope_exit.hpp

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions include/boost/scope/scope_fail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <type_traits>
#include <boost/scope/detail/config.hpp>
#include <boost/scope/exception_checker.hpp>
#include <boost/scope/scope_check.hpp>
#include <boost/scope/scope_exit.hpp>
#include <boost/scope/detail/is_not_like.hpp>
#include <boost/scope/detail/type_traits/conjunction.hpp>
#include <boost/scope/detail/type_traits/is_invocable.hpp>
Expand Down Expand Up @@ -59,19 +59,19 @@ using is_not_like_scope_fail = detail::is_not_like< T, scope_fail >;
* due to an exception - the action function object will not be called if
* the scope is left normally.
*
* \sa scope_check
* \sa scope_exit
* \sa scope_success
*
* \tparam Func Scope guard action function object type.
* \tparam Cond Scope guard failure condition function object type.
*/
template< typename Func, typename Cond = exception_checker >
class scope_fail :
public scope_check< Func, Cond >
public scope_exit< Func, Cond >
{
//! \cond
private:
typedef scope_check< Func, Cond > base_type;
typedef scope_exit< Func, Cond > base_type;

//! \endcond
public:
Expand Down
8 changes: 4 additions & 4 deletions include/boost/scope/scope_success.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <type_traits>
#include <boost/scope/detail/config.hpp>
#include <boost/scope/exception_checker.hpp>
#include <boost/scope/scope_check.hpp>
#include <boost/scope/scope_exit.hpp>
#include <boost/scope/detail/is_not_like.hpp>
#include <boost/scope/detail/type_traits/conjunction.hpp>
#include <boost/scope/detail/type_traits/is_invocable.hpp>
Expand Down Expand Up @@ -103,19 +103,19 @@ class logical_not
* due to an exception - the action function object will only be called if
* the scope is left normally.
*
* \sa scope_check
* \sa scope_exit
* \sa scope_fail
*
* \tparam Func Scope guard action function object type.
* \tparam Cond Scope guard failure condition function object type.
*/
template< typename Func, typename Cond = exception_checker >
class scope_success :
public scope_check< Func, detail::logical_not< Cond > >
public scope_exit< Func, detail::logical_not< Cond > >
{
//! \cond
private:
typedef scope_check< Func, detail::logical_not< Cond > > base_type;
typedef scope_exit< Func, detail::logical_not< Cond > > base_type;

//! \endcond
public:
Expand Down
1 change: 1 addition & 0 deletions test/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ project
cxx11_lambdas
cxx11_auto_declarations
cxx11_unified_initialization_syntax
cxx11_hdr_system_error
]
;

Expand Down
26 changes: 0 additions & 26 deletions test/compile_fail/scope_check_noncopyable.cpp

This file was deleted.

Loading

0 comments on commit 04ab51c

Please sign in to comment.