opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
scoped_lifetime.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace osc
7{
8 // a managed, reference-counted, watchable lifetime that's strongly tied
9 // to its position in memory (scope) - to the point that copying, moving,
10 // or assigning it resets the lifetime
12 public:
13 // constructs a new lifetime
14 ScopedLifetime() = default;
15
16 // constructs a new lifetime
18
19 // constructs a new lifetime
21
22 // replaces the lifetime with a new lifetime
24 {
25 if (&rhs == this) {
26 return *this;
27 }
28
29 lifetime_block_ = SharedLifetimeBlock{};
30 return *this;
31 }
32
33 // replaces the lifetime with a new lifetime
35 {
36 return *this = static_cast<const ScopedLifetime&>(rhs);
37 }
38
40
41 LifetimeWatcher watch() const { return lifetime_block_.watch(); }
42 private:
43 SharedLifetimeBlock lifetime_block_;
44 };
45}
Definition lifetime_watcher.h:11
Definition scoped_lifetime.h:11
LifetimeWatcher watch() const
Definition scoped_lifetime.h:41
ScopedLifetime(const ScopedLifetime &)
Definition scoped_lifetime.h:17
~ScopedLifetime() noexcept=default
ScopedLifetime & operator=(ScopedLifetime &&rhs) noexcept
Definition scoped_lifetime.h:34
ScopedLifetime & operator=(const ScopedLifetime &rhs)
Definition scoped_lifetime.h:23
ScopedLifetime()=default
ScopedLifetime(ScopedLifetime &&) noexcept
Definition scoped_lifetime.h:20
Definition shared_lifetime_block.h:10
LifetimeWatcher watch() const
Definition shared_lifetime_block.h:12
Definition custom_decoration_generator.h:5
constexpr U to(T &&value)
Definition conversion.h:56