Created
November 8, 2017 03:12
-
-
Save adiog/9345048026827f66807655b1f20e43b4 to your computer and use it in GitHub Desktop.
copy-based-history
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cassert> | |
template <typename T> | |
using history_t = std::vector<T>; | |
template <typename T> | |
void commit(history_t<T>& h) { assert(h.size()); h.push_back(h.back()); } | |
template <typename T> | |
void undo(history_t<T>& h) { assert(h.size()); h.pop_back(); } | |
template <typename T> | |
T& current(history_t<T>& h) { assert(h.size()); return h.back();} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment