libcwdversion 2.0.0
The C++ Debugging Support Library
Loading...
Searching...
No Matches
DebugStack.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2000-2005, 2018, 2020, 2023, 2026 Carlo Wood
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
9
10#ifndef LIBCWD_PRIVATE_DEBUG_STACK_H
11#define LIBCWD_PRIVATE_DEBUG_STACK_H
12
13#include "libcwd/config.h"
14
15#include <cstddef> // Needed for size_t
16
17#ifndef HIDE_FROM_DOXYGEN
18namespace libcwd::_private_ {
19
20// Stack implementation that doesn't have a constructor.
21// The size of 64 should be MORE then enough.
22
23template <typename T> // T must be a builtin type.
24struct DebugStack
25{
26 public:
27 static constexpr int max_size = 64;
28
29 private:
30 T stack_[max_size];
31 T* current_;
32 T* end_;
33
34 public:
35 void init();
36 void push(T ptr);
37 void pop();
38 T top() const;
39 size_t size() const;
40};
41
42} // namespace libcwd::_private_
43#endif // HIDE_FROM_DOXYGEN
44
45#endif // LIBCWD_PRIVATE_DEBUG_STACK_H