resolve cyclic dependency with zstd
[platform/upstream/cmake.git] / Source / cmConstStack.tcc
1 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2    file Copyright.txt or https://cmake.org/licensing for details.  */
3
4 #include <cassert>
5 #include <memory>
6 #include <utility>
7
8 template <typename T, typename Stack>
9 struct cmConstStack<T, Stack>::Entry
10 {
11   Entry(std::shared_ptr<Entry const> parent, T value)
12     : Value(std::move(value))
13     , Parent(std::move(parent))
14   {
15   }
16
17   T Value;
18   std::shared_ptr<Entry const> Parent;
19 };
20
21 template <typename T, typename Stack>
22 cmConstStack<T, Stack>::cmConstStack() = default;
23
24 template <typename T, typename Stack>
25 Stack cmConstStack<T, Stack>::Push(T value) const
26 {
27   return Stack(this->TopEntry, std::move(value));
28 }
29
30 template <typename T, typename Stack>
31 Stack cmConstStack<T, Stack>::Pop() const
32 {
33   assert(this->TopEntry);
34   return Stack(this->TopEntry->Parent);
35 }
36
37 template <typename T, typename Stack>
38 T const& cmConstStack<T, Stack>::Top() const
39 {
40   assert(this->TopEntry);
41   return this->TopEntry->Value;
42 }
43
44 template <typename T, typename Stack>
45 bool cmConstStack<T, Stack>::Empty() const
46 {
47   return !this->TopEntry;
48 }
49
50 template <typename T, typename Stack>
51 cmConstStack<T, Stack>::cmConstStack(std::shared_ptr<Entry const> parent,
52                                      T value)
53   : TopEntry(
54       std::make_shared<Entry const>(std::move(parent), std::move(value)))
55 {
56 }
57
58 template <typename T, typename Stack>
59 cmConstStack<T, Stack>::cmConstStack(std::shared_ptr<Entry const> top)
60   : TopEntry(std::move(top))
61 {
62 }