Commit 454bd1cb authored by Ilya Prokhorov's avatar Ilya Prokhorov

SharedNotNullPointer pre implementation

parent 45eb6ac6
#ifndef FLAMESTEELCORESHAREDNOTNULLPOINTER_H_
#define FLAMESTEELCORESHAREDNOTNULLPOINTER_H_
#include <memory>
#include "Utils.h"
using namespace std;
using namespace FlameSteelCore::Utils;
namespace FlameSteelCore {
namespace Utils {
template <typename T>
class SharedNotNullPointer {
public:
SharedNotNullPointer(shared_ptr<T> rawSharedPointer) {
if (rawSharedPointer.get() == nullptr) {
throwRuntimeException("Excepted not null, but got null shared_ptr at SharedNotNullPointer constructor");
}
this->rawSharedPointer = rawSharedPointer;
};
shared_ptr<T> operator->() {
if (rawSharedPointer.get() == nullptr) {
throwRuntimeException("Excepted not null, but got null shared_ptr at SharedNotNullPointer getter");
}
return rawSharedPointer;
}
private:
shared_ptr<T> rawSharedPointer;
};
};
};
#endif
\ No newline at end of file
#include "FSCUtils.h"
namespace FlameSteelCore {
namespace Utils {
void throwRuntimeException(char *errorText) {
throwRuntimeException(string(errorText));
};
};
};
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment