CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Util
ScopedStack.h
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#pragma once
8
9
#include <deque>
10
#include <memory>
11
12
/// A stack to keep track of nested scopes.
13
template
<
typename
T>
14
class
FScopedStack
:
private
std::deque<T> {
15
using
Super
= std::deque<T>;
16
public
:
17
18
/// Push this scope into the stack. Automatically pops @a Value when the
19
/// returned object goes out of the scope.
20
template
<
typename
V>
21
auto
PushScope
(V &&Value)
22
{
23
Super::emplace_back(std::forward<V>(Value));
24
T *Pointer = &Super::back();
25
auto
Deleter = [
this
](
const
T *) { Super::pop_back(); };
26
return
std::unique_ptr<T, decltype(Deleter)>(Pointer, Deleter);
27
}
28
29
using
Super::empty;
30
using
Super::size;
31
using
Super::begin;
32
using
Super::end;
33
};
FScopedStack
A stack to keep track of nested scopes.
Definition
ScopedStack.h:14
FScopedStack::PushScope
auto PushScope(V &&Value)
Push this scope into the stack.
Definition
ScopedStack.h:21
FScopedStack::Super
std::deque< T > Super
Definition
ScopedStack.h:15
Generated by
1.18.0