Changeset a381b46 for doc/generic_types/evaluation/cpp-vstack.cpp
- Timestamp:
- Apr 15, 2017, 7:09:59 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- c57d1935
- Parents:
- 308880c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/generic_types/evaluation/cpp-vstack.cpp
r308880c ra381b46 1 1 #include "cpp-vstack.hpp" 2 3 2 #include <utility> 4 3 5 4 stack::node::node( const object& v ) : value( v.new_copy() ), next( nullptr ) {} 6 7 5 stack::node::node( ptr<object>&& v, node* n ) : value( std::move(v) ), next( n ) {} 8 6 … … 18 16 } 19 17 20 void stack::clear() {21 node* next = head;22 while ( next ) {23 node* crnt = next;24 next = crnt->next;25 delete crnt;26 }27 head = nullptr;28 }29 30 18 stack::stack() : head(nullptr) {} 31 32 19 stack::stack(const stack& o) { copy(o); } 33 34 20 stack::stack(stack&& o) : head(o.head) { o.head = nullptr; } 35 36 21 stack::~stack() { clear(); } 37 22 … … 50 35 } 51 36 37 void stack::clear() { 38 node* next = head; 39 while ( next ) { 40 node* crnt = next; 41 next = crnt->next; 42 delete crnt; 43 } 44 head = nullptr; 45 } 46 47 52 48 bool stack::empty() const { return head == nullptr; } 53 49
Note: See TracChangeset
for help on using the changeset viewer.