Files
Aerofoil/PortabilityLayer/PLUnalignedPtr.h
Diomendius 1b18a87495 Normalize line endings
This commit contains only the result of `git add --renormalize .`

`git show --ignore-space-change` can verify that this commit only
changes whitespace.
2024-07-31 20:21:47 +12:00

50 lines
661 B
C++

#pragma once
namespace PortabilityLayer
{
template<class T>
class UnalignedPtr
{
public:
UnalignedPtr();
explicit UnalignedPtr(const T *ref);
const T *GetRawPtr() const;
T Get() const;
private:
const T *m_ref;
};
template<class T>
UnalignedPtr<T>::UnalignedPtr()
: m_ref(nullptr)
{
}
template<class T>
UnalignedPtr<T>::UnalignedPtr(const T *ref)
: m_ref(ref)
{
}
}
#include <string.h>
namespace PortabilityLayer
{
template<class T>
const T *UnalignedPtr<T>::GetRawPtr() const
{
return m_ref;
}
template<class T>
T UnalignedPtr<T>::Get() const
{
T result;
memcpy(&result, m_ref, sizeof(T));
return result;
}
}