#pragma once #include #include "OptionalRef.h" namespace crepe { template OptionalRef::OptionalRef(T & ref) { this->ref = &ref; } template OptionalRef::operator T &() const { if (this->ref == nullptr) throw std::runtime_error("OptionalRef: attempt to dereference nullptr"); return *this->ref; } template OptionalRef & OptionalRef::operator=(T & ref) { this->ref = &ref; return *this; } template OptionalRef::operator bool() const noexcept { return this->ref != nullptr; } template void OptionalRef::clear() noexcept { this->ref = nullptr; } } // namespace crepe