/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file LICENSE.rst or https://cmake.org/licensing for details. */ #include #include #include template struct cmStackEntry { cmStackEntry(std::shared_ptr parent, T value) : Value(std::move(value)) , Parent(std::move(parent)) { } T mutable Value; std::shared_ptr Parent; }; template struct cmStackEntry { cmStackEntry(std::shared_ptr parent, T value) : Value(std::move(value)) , Parent(std::move(parent)) { } T Value; std::shared_ptr Parent; }; template cmStack::cmStack() = default; template Stack cmStack::Push(T value) const { return Stack(this->TopEntry, std::move(value)); } template Stack cmStack::Pop() const { assert(this->TopEntry); return Stack(this->TopEntry->Parent); } template T const& cmStack::Top() const { assert(this->TopEntry); return this->TopEntry->Value; } template template typename std::enable_if::type& cmStack::Top() { static_assert(Mutable == cmStackType::Mutable, "T& cmStack::Top should only exist for mutable cmStack"); assert(this->TopEntry); return this->TopEntry->Value; } template bool cmStack::Empty() const { return !this->TopEntry; } template cmStack::cmStack(std::shared_ptr parent, T value) : TopEntry( std::make_shared(std::move(parent), std::move(value))) { } template cmStack::cmStack(std::shared_ptr top) : TopEntry(std::move(top)) { }