Immutable ScriptsContainerLifetime
| 20 | |
| 21 | // Immutable ScriptsContainerLifetime |
| 22 | class ScriptsContainerWeakPtr |
| 23 | { |
| 24 | ScriptsContainerLifetime mWeakPtr; |
| 25 | |
| 26 | public: |
| 27 | ScriptsContainerWeakPtr(const ScriptsContainerWeakPtr&) = default; |
| 28 | ScriptsContainerWeakPtr(ScriptsContainerWeakPtr&&) = default; |
| 29 | |
| 30 | explicit ScriptsContainerWeakPtr(ScriptsContainerLifetime ptr) |
| 31 | : mWeakPtr(std::move(ptr)) |
| 32 | { |
| 33 | } |
| 34 | |
| 35 | ScriptsContainer* operator*() const noexcept |
| 36 | { |
| 37 | if (auto ptr = mWeakPtr.get()) |
| 38 | return *ptr; |
| 39 | // this shouldn't happen unless you use it after a move or try to be funny by constructing from nullptr |
| 40 | return nullptr; |
| 41 | } |
| 42 | }; |
| 43 | |
| 44 | inline auto operator<=>(const ScriptsContainerWeakPtr& lhs, const ScriptsContainerWeakPtr& rhs) |
| 45 | { |