diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2013-05-13 22:28:41 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2013-05-15 18:56:01 -0700 |
commit | 6ffe0682ab798155129f53b768cb881eac730a1f (patch) | |
tree | a603424c1fa7a5516dddf30ae9d801f5a16b1fc6 /src/common/timer.t.hpp | |
parent | 3f44f25774a84cd95ed47c249a8f5aeee3ea8676 (diff) | |
download | tmwa-6ffe0682ab798155129f53b768cb881eac730a1f.tar.gz tmwa-6ffe0682ab798155129f53b768cb881eac730a1f.tar.bz2 tmwa-6ffe0682ab798155129f53b768cb881eac730a1f.tar.xz tmwa-6ffe0682ab798155129f53b768cb881eac730a1f.zip |
Add a dumb_ptr template for transition purposes
Diffstat (limited to 'src/common/timer.t.hpp')
-rw-r--r-- | src/common/timer.t.hpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/common/timer.t.hpp b/src/common/timer.t.hpp index ee9b5d2..1e3a87a 100644 --- a/src/common/timer.t.hpp +++ b/src/common/timer.t.hpp @@ -4,6 +4,8 @@ # include <chrono> # include <functional> +# include "dumb_ptr.hpp" + struct TimerData; /// An implementation of the C++ "clock" concept, exposing @@ -30,13 +32,13 @@ typedef std::function<void (TimerData *, tick_t)> timer_func; class Timer { friend struct TimerData; - TimerData *td; + dumb_ptr<TimerData> td; Timer(const Timer&) = delete; Timer& operator = (const Timer&) = delete; public: /// Don't own anything yet. - Timer() : td(nullptr) {} + Timer() = default; /// Schedule a timer for the given tick. /// If you do not wish to keep track of it, call disconnect(). /// Otherwise, you may cancel() or replace (operator =) it later. @@ -58,7 +60,7 @@ public: void detach(); /// Check if there is a timer connected. - explicit operator bool() { return td; } + explicit operator bool() { return bool(td); } /// Check if there is no connected timer. bool operator !() { return !td; } }; |