WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
wpi::memory::memory_stack_raii_unwind< Stack > Class Template Reference

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

#include <wpi/memory/memory_stack.hpp>

Public Types

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

Public 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_typeget_stack () const noexcept
 

Detailed Description

template<class Stack = memory_stack<>>
class wpi::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 wpi::memory::memory_stack

Member Typedef Documentation

◆ marker_type

template<class Stack = memory_stack<>>
using wpi::memory::memory_stack_raii_unwind< Stack >::marker_type = typename stack_type::marker

◆ stack_type

template<class Stack = memory_stack<>>
using wpi::memory::memory_stack_raii_unwind< Stack >::stack_type = Stack

Constructor & Destructor Documentation

◆ memory_stack_raii_unwind() [1/3]

template<class Stack = memory_stack<>>
wpi::memory::memory_stack_raii_unwind< Stack >::memory_stack_raii_unwind ( stack_type & stack)
inlineexplicitnoexcept
Effects:
Same as memory_stack_raii_unwind(stack, stack.top()).

◆ memory_stack_raii_unwind() [2/3]

template<class Stack = memory_stack<>>
wpi::memory::memory_stack_raii_unwind< Stack >::memory_stack_raii_unwind ( stack_type & stack,
marker_type marker )
inlinenoexcept
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]

template<class Stack = memory_stack<>>
wpi::memory::memory_stack_raii_unwind< Stack >::memory_stack_raii_unwind ( memory_stack_raii_unwind< Stack > && other)
inlinenoexcept
Effects:
Move constructs the unwinder by taking the saved position from other. other.will_unwind() will return false after it.

◆ ~memory_stack_raii_unwind()

template<class Stack = memory_stack<>>
wpi::memory::memory_stack_raii_unwind< Stack >::~memory_stack_raii_unwind ( )
inlinenoexcept
Effects:
Unwinds to the previously saved location, if there is any, by calling unwind().

Member Function Documentation

◆ get_marker()

template<class Stack = memory_stack<>>
marker_type wpi::memory::memory_stack_raii_unwind< Stack >::get_marker ( ) const
inlinenoexcept
Returns:
The saved marker, if there is any.
Requires:
will_unwind() must return true.

◆ get_stack()

template<class Stack = memory_stack<>>
stack_type & wpi::memory::memory_stack_raii_unwind< Stack >::get_stack ( ) const
inlinenoexcept
Returns:
The stack it will unwind.
Requires:
will_unwind() must return true.

◆ operator=()

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

◆ release()

template<class Stack = memory_stack<>>
void wpi::memory::memory_stack_raii_unwind< Stack >::release ( )
inlinenoexcept
Effects:
Removes the location without unwinding it. will_unwind() will return false.

◆ unwind()

template<class Stack = memory_stack<>>
void wpi::memory::memory_stack_raii_unwind< Stack >::unwind ( )
inlinenoexcept
Effects:
Unwinds to the saved location explictly.
Requires:
will_unwind() must return true.

◆ will_unwind()

template<class Stack = memory_stack<>>
bool wpi::memory::memory_stack_raii_unwind< Stack >::will_unwind ( ) const
inlinenoexcept
Returns:
Whether or not the unwinder will actually unwind.
Note
It will not unwind if it is in the moved-from state.

The documentation for this class was generated from the following file: