opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
lifetime_watcher.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
5namespace osc
6{
7 class SharedLifetimeBlock;
8
9 // a non-owning reference to a lifetime block that can be queried at
10 // runtime (via `expired`) to check if the lifetime is still alive
12 public:
13 constexpr LifetimeWatcher() = default;
14
15 bool expired() const noexcept { return ptr_.expired(); }
16 private:
17 friend class SharedLifetimeBlock;
18 explicit LifetimeWatcher(const std::shared_ptr<int>& ptr) :
19 ptr_{ptr}
20 {}
21
22 std::weak_ptr<int> ptr_;
23 };
24}
Definition lifetime_watcher.h:11
bool expired() const noexcept
Definition lifetime_watcher.h:15
constexpr LifetimeWatcher()=default
Definition shared_lifetime_block.h:10
Definition custom_decoration_generator.h:5
constexpr U to(T &&value)
Definition conversion.h:56