:relfileprefix: ../../
[#EC05528198EA87FCCFB1FF9472304396154D4EB5]

= Class scope_success

pass:v,q[Scope exit guard that invokes a function upon leaving the scope with] pass:v,q[a failure condition not satisfied.]


== Synopsis

Declared in header `<https://github.com/Lastique/scope/blob/develop/include/boost/scope/scope_success.hpp#L116[boost/scope/scope_success.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
template<
    typename Func,
    typename Cond = xref:boost/scope/exception_checker.adoc[exception_checker]>
class scope_success
    : public xref:boost/scope/scope_exit-0a.adoc[scope_exit]<Func, logical_not<Cond>>;
----

==  Member Functions
[,cols=2]
|===
|Name |Description
|xref:boost/scope/scope_exit-0a/active.adoc[`pass:v[active]`] |
pass:v,q[Returns] `true` pass:v,q[if the scope guard is active, otherwise] `false.`

|xref:boost/scope/scope_exit-0a/operator_assign.adoc[`pass:v[operator=]`] |
|xref:boost/scope/scope_exit-0a/release.adoc[`pass:v[release]`] |
pass:v,q[Deactivates the scope guard.]

|xref:boost/scope/scope_success-0ec/2constructor.adoc[`pass:v[scope_success]`] |
|xref:boost/scope/scope_exit-0a/set_active.adoc[`pass:v[set_active]`] |
pass:v,q[Activates or deactivates the scope guard.]

|===

== Description

pass:v,q[The scope guard wraps two function objects: the scope guard action and]
pass:v,q[a failure condition for invoking the action. Both function objects must]
pass:v,q[be callable with no arguments and can be one of:]

* pass:v,q[A user-defined class with a public `operator()`.]

* pass:v,q[An lvalue reference to such class.]

* pass:v,q[An lvalue reference or pointer to function taking no arguments.]
pass:v,q[The condition function object `operator()` must return a value]
pass:v,q[contextually convertible to]
`true,`
pass:v,q[if the failure is detected and the]
pass:v,q[action function object is not allowed to be executed, and]
`false`
pass:v,q[otherwise.]
pass:v,q[Additionally, the failure condition function object `operator()` must not]
pass:v,q[throw, as otherwise the action function object may not be called. If not]
pass:v,q[specified, the default failure condition checks whether the scope is left]
pass:v,q[due to an exception - the action function object will only be called if]
pass:v,q[the scope is left normally.]



