16 std::shared_ptr<const Snapshot<T>> snapshot;
18 std::deque<std::shared_ptr<Item>> undo_stack, redo_stack;
19 std::shared_ptr<Item> current;
28 bool canUndo()
const {
return !undo_stack.empty(); }
30 if (canUndo() && !locked) {
31 redo_stack.push_front(current);
32 current = undo_stack.back();
33 undo_stack.pop_back();
35 if (undo_stack.size() + redo_stack.size() > limit) {
36 redo_stack.pop_back();
38 current->snapshot->apply(v);
41 bool canRedo()
const {
return !redo_stack.empty(); }
43 if (canRedo() && !locked) {
44 undo_stack.push_back(current);
46 current = redo_stack.front();
47 redo_stack.pop_front();
48 if (undo_stack.size() + redo_stack.size() > limit) {
49 undo_stack.pop_front();
51 current->snapshot->apply(v);