mirror of
https://github.com/boostorg/scope.git
synced 2026-01-27 19:32:07 +00:00
The new scope_check scope guard is a generalization of scope_success and scope_fail and allows specifying arbitrary conditions for executing the scope exit action. The scope_success and scope_fail have been reimplemented in terms of scope_check and now also support arbitrary fail conditions. Added exception_checker and error_code_checker conditions for testing for an exception being thrown and for an error code, respectively. scope_success and scope_fail use exception_checker by default. Added tests for the new components.
27 lines
624 B
C++
27 lines
624 B
C++
/*
|
|
* Distributed under the Boost Software License, Version 1.0.
|
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
|
* https://www.boost.org/LICENSE_1_0.txt)
|
|
*
|
|
* Copyright (c) 2023 Andrey Semashev
|
|
*/
|
|
/*!
|
|
* \file scope_final_nonmoveable.cpp
|
|
* \author Andrey Semashev
|
|
*
|
|
* \brief This file tests that \c scope_final is nonmoveable.
|
|
*/
|
|
|
|
#include <boost/scope/scope_final.hpp>
|
|
#include <utility>
|
|
#include "function_types.hpp"
|
|
|
|
int main()
|
|
{
|
|
int n = 0;
|
|
boost::scope::scope_final< normal_func > guard1{ normal_func(n) };
|
|
boost::scope::scope_final< normal_func > guard2 = std::move(guard1);
|
|
|
|
return 0;
|
|
}
|