acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
scope_stack.h
1//
2// Created by camilo on 2022-10-23 09:24 <3ThomasBorregaardSorensen!!
3//
4#pragma once
5
6
7template < typename T >
8class scope_stack
9{
10public:
11
12
13 T & m_reference;
14 T m_tPrevious;
15
16
17 scope_stack(T& reference, const T& tStack) :
18 m_reference(reference)
19 {
20
21 m_tPrevious = reference;
22
23 reference = tStack;
24
25 }
26
27
28 ~scope_stack()
29 {
30
31 m_reference = m_tPrevious;
32
33 }
34
35
36};
37
38
39#define __scope_stack(xxxx, aaaa) auto stack_at_line ## LINE_NUMBER = ::scope_stack < ::non_reference< decltype(xxxx) >::TYPE > (xxxx, aaaa);
40
41
42