Skip to content

Commit

Permalink
Allow just releasing lifetimes without invoking.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Apr 10, 2020
1 parent 9f3bb0e commit df918b9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions rpl/lifetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class lifetime {
void add(lifetime &&other);
void destroy();

void release();

template <typename Type, typename... Args>
Type *make_state(Args&& ...args) {
const auto result = new Type(std::forward<Args>(args)...);
Expand Down Expand Up @@ -86,4 +88,19 @@ inline void lifetime::destroy() {
}
}

inline void lifetime::release() {
_callbacks.clear();
}

struct release_t {
};

inline release_t release() {
return {};
}

inline void operator|(rpl::lifetime &&lifetime, release_t) {
lifetime.release();
}

} // namespace rpl

0 comments on commit df918b9

Please sign in to comment.