Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::experi...ope_success(3)  C++ Standard Libary std::experi...ope_success(3)

NAME
       std::experimental::scope_success	- std::experimental::scope_success

Synopsis
	  Defined in header <experimental/scope>
	  template<class EF>			  (library fundamentals	TS v3)
	  class	scope_success;

	  The  class  template	scope_success is a general-purpose scope guard
       intended	to call
	  its exit function when a scope is normally exited.

	  scope_success	is not CopyConstructible,  CopyAssignable  or  MoveAs-
       signable, however,
	  it  may  be  MoveConstructible  if EF	meets some requirements, which
       permits wrapping	a
	  scope_success	into another object.

	  A scope_success may be either	active,	i.e. calls its	exit  function
       on destruction,
	  or  inactive,	 i.e.  does nothing on destruction. A scope_success is
       active after
	  constructed from an exit function.

	  A scope_success can become inactive by calling release() on  it  ei-
       ther manually or
	  automatically	 (by  the move constructor). An	inactive scope_success
       may also	be
	  obtained by initializing with	another	inactive scope_success.	Once a
       scope_success
	  is inactive, it cannot become	active again.

	  A scope_success effectively holds an EF and a	bool  flag  indicating
       if it is	active,
	  alongwith  a	counter	 of  uncaught  exceptions  used	 for detecting
       whether the destructor
	  is called during stack unwinding.

Template parameters
	  EF			-		    type of stored exit	 func-
       tion

Type requirements
	  -
	  EF shall be either:

	    * a	Destructible FunctionObject type
	    * an lvalue	reference to FunctionObject
	    * an lvalue	reference to function
	  -
	  Calling  an  lvalue  of std::remove_reference_t<EF> with no argument
       shall be
	  well-formed.

Member functions
	  constructor	constructs a new scope_success
			(public	member function)
			calls the exit function	when the scope is exited  nor-
       mally if	the
	  destructor	 scope_success is active, then destroys	the scope_suc-
       cess
			(public	member function)
	  operator=	scope_success is not assignable
	  [deleted]	(public	member function)

Modifiers
	  release	makes the scope_success	inactive
			(public	member function)

	 Deduction guides

Notes
	  Constructing a scope_success of dynamic storage duration might  lead
       to unexpected
	  behavior.

	  Constructing	a scope_success	is constructed from another scope_suc-
       cess created in a
	  different thread might also lead to unexpected  behavior  since  the
       count of	uncaught
	  exceptions  obtained in different threads may	be compared during the
       destruction.

	  If the EF stored in a	scope_success object refers to a  local	 vari-
       able of the
	  function  where it is	defined, e.g., as a lambda capturing the vari-
       able by reference,
	  and that variable is used as a return	operand	in that	function, that
       variable	might
	  have already been returned when the scope_success's destructor  exe-
       cutes, calling the
	  exit function. This can lead to surprising behavior.

Example
	   This	section	is incomplete
	   Reason: no example

See also
	  scope_exit	 wraps a function object and invokes it	on exiting the
       scope
			 (class	template)
			 wraps a function object and invokes it	on exiting the
       scope through
	  scope_fail	 an exception
			 (class	template)
	  default_delete default deleter for unique_ptr
	  (C++11)	 (class	template)

http://cppreference.com		  2022.07.31	  std::experi...ope_success(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::experimental::scope_success&sektion=3&manpath=FreeBSD+Ports+15.0>

home | help