aboutsummaryrefslogtreecommitdiff
path: root/source/include/memory/asm_pointer.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/include/memory/asm_pointer.hpp')
-rw-r--r--source/include/memory/asm_pointer.hpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/source/include/memory/asm_pointer.hpp b/source/include/memory/asm_pointer.hpp
new file mode 100644
index 0000000..ec7141e
--- /dev/null
+++ b/source/include/memory/asm_pointer.hpp
@@ -0,0 +1,43 @@
+#ifndef TEACHOS_BOOT_ASM_POINTER_HPP
+#define TEACHOS_BOOT_ASM_POINTER_HPP
+
+namespace teachos::boot
+{
+
+ template<typename Type>
+ struct asm_pointer
+ {
+ constexpr asm_pointer(Type & pointer)
+ : m_pointer{&pointer}
+ {
+ }
+
+ auto constexpr operator->() -> Type * { return m_pointer; }
+ auto constexpr operator->() const -> Type const * { return m_pointer; }
+ auto constexpr operator*() -> Type & { return *m_pointer; }
+ auto constexpr operator*() const -> Type const & { return *m_pointer; }
+
+ private:
+ Type * m_pointer;
+ };
+
+ template<typename Type>
+ struct asm_pointer<Type const>
+ {
+ constexpr asm_pointer(Type const & pointer)
+ : m_pointer{&pointer}
+ {
+ }
+
+ auto constexpr operator->() -> Type const * { return m_pointer; }
+ auto constexpr operator->() const -> Type const * { return m_pointer; }
+ auto constexpr operator*() -> Type const & { return *m_pointer; }
+ auto constexpr operator*() const -> Type const & { return *m_pointer; }
+
+ private:
+ Type const * m_pointer;
+ };
+
+} // namespace teachos::boot
+
+#endif \ No newline at end of file