Documentation of memory

( foonathan/memory)

memory_stack_raii_unwind< Stack > Class Template Reference

Detailed Description

template<class Stack = memory_stack<>>
class foonathan::memory::memory_stack_raii_unwind< Stack >

Simple utility that automatically unwinds a Stack to a previously saved location.

A Stack is anything that provides a marker, a top() function returning a marker and an unwind() function to unwind to a marker, like a foonathan::memory::memory_stack

Typedefs

using stack_type = Stack
 
using marker_type = typename stack_type::marker
 

Member Functions

 memory_stack_raii_unwind (stack_type &stack) noexcept
 
 memory_stack_raii_unwind (stack_type &stack, marker_type marker) noexcept
 
 memory_stack_raii_unwind (memory_stack_raii_unwind &&other) noexcept
 
 ~memory_stack_raii_unwind () noexcept
 
memory_stack_raii_unwindoperator= (memory_stack_raii_unwind &&other) noexcept
 
void release () noexcept
 
void unwind () noexcept
 
bool will_unwind () const noexcept
 
marker_type get_marker () const noexcept
 
stack_type & get_stack () const noexcept
 

Constructors

§ memory_stack_raii_unwind() [1/3]

memory_stack_raii_unwind ( stack_type &  stack)
explicitnoexcept
Effects:
Same as memory_stack_raii_unwind(stack, stack.top()).

§ memory_stack_raii_unwind() [2/3]

memory_stack_raii_unwind ( stack_type &  stack,
marker_type  marker 
)
noexcept
Effects:
Creates the unwinder by giving it the stack and the marker.
Requires:
The stack must live longer than this object.

§ memory_stack_raii_unwind() [3/3]

memory_stack_raii_unwind ( memory_stack_raii_unwind< Stack > &&  other)
noexcept
Effects:
Move constructs the unwinder by taking the saved position from other. other.will_unwind() will return false after it.

§ ~memory_stack_raii_unwind()

~memory_stack_raii_unwind ( )
noexcept
Effects:
Unwinds to the previously saved location, if there is any, by calling unwind().

Member Functions

§ operator=()

memory_stack_raii_unwind& operator= ( memory_stack_raii_unwind< Stack > &&  other)
noexcept
Effects:
Move assigns the unwinder by taking the saved position from other. other.will_unwind() will return false after it.

§ release()

void release ( )
noexcept
Effects:
Removes the location without unwinding it. will_unwind() will return false.

§ unwind()

void unwind ( )
noexcept
Effects:
Unwinds to the saved location explictly.
Requires:
will_unwind() must return true.

§ will_unwind()

bool will_unwind ( ) const
noexcept
Returns:
Whether or not the unwinder will actually unwind.
Note
It will not unwind if it is in the moved-from state.

§ get_marker()

marker_type get_marker ( ) const
noexcept
Returns:
The saved marker, if there is any.
Requires:
will_unwind() must return true.

§ get_stack()

stack_type& get_stack ( ) const
noexcept
Returns:
The stack it will unwind.
Requires:
will_unwind() must return true.