mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
79676aee15
Engine controls lifetime of managers therefore it should own them. Environment is only access provider. This allows to avoid redundant virtual calls and also some functions from managers base classes can be removed if they are used only by Engine.
34 lines
590 B
C++
34 lines
590 B
C++
#ifndef OPENMW_COMPONENTS_MISC_NOTNULLPTR_H
|
|
#define OPENMW_COMPONENTS_MISC_NOTNULLPTR_H
|
|
|
|
#include <cassert>
|
|
#include <cstddef>
|
|
#include <type_traits>
|
|
|
|
namespace Misc
|
|
{
|
|
template <class T>
|
|
class NotNullPtr
|
|
{
|
|
public:
|
|
NotNullPtr(T* value)
|
|
: mValue(value)
|
|
{
|
|
assert(mValue != nullptr);
|
|
}
|
|
|
|
NotNullPtr(std::nullptr_t) = delete;
|
|
|
|
operator T*() const { return mValue; }
|
|
|
|
T* operator->() const { return mValue; }
|
|
|
|
T& operator*() const { return *mValue; }
|
|
|
|
private:
|
|
T* mValue;
|
|
};
|
|
}
|
|
|
|
#endif
|