Add get() functionality to static_pointer
All checks were successful
continuous-integration/drone/push Build is passing
gitea/skullc-peripherals/pipeline/head This commit looks good

This commit is contained in:
Erki 2022-06-30 19:46:56 +03:00
parent eef2e1318c
commit 0ba9416a57
2 changed files with 15 additions and 1 deletions

View File

@ -8,8 +8,11 @@
#ifndef SKULLC_UTILITY_STATICPOINTER_HPP_
#define SKULLC_UTILITY_STATICPOINTER_HPP_
#include <new>
#include <utility>
#include <utility_assert.hpp>
namespace Utility
{
@ -57,6 +60,17 @@ struct StaticPointer
return initialized_;
}
value_type* get()
{
SKULLC_ASSERT_DEBUG(initialized_);
return reinterpret_cast<value_type*>(storage);
}
const value_type* get() const
{
SKULLC_ASSERT_DEBUG(initialized_);
return reinterpret_cast<const value_type*>(storage);
}
private:
bool initialized_ = false;
};