From befde76cfa46c766e81f74eb5ac65d3dae2dde87 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 19 Apr 2025 17:33:26 +0200 Subject: dev, LibCompiler, tooling: refactor and separate components into modules (cppdrv, cxxdrv) Signed-off-by: Amlal El Mahrouss --- dev/LibCompiler/NFC/Ref.h | 103 ---------------------------------------------- 1 file changed, 103 deletions(-) delete mode 100644 dev/LibCompiler/NFC/Ref.h (limited to 'dev/LibCompiler/NFC/Ref.h') diff --git a/dev/LibCompiler/NFC/Ref.h b/dev/LibCompiler/NFC/Ref.h deleted file mode 100644 index 117083c..0000000 --- a/dev/LibCompiler/NFC/Ref.h +++ /dev/null @@ -1,103 +0,0 @@ - -/* - * ======================================================== - * - * LibCompiler - * Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved. - * - * ======================================================== - */ - -#pragma once - -#include - -namespace LibCompiler -{ - // @author EL Mahrouss Amlal - // @brief Reference holder class, refers to a pointer of data in static memory. - template - class Ref final - { - public: - explicit Ref() = default; - - ~Ref() - { - if (m_Strong) - { - (*m_Class).~T(); - } - } - - LIBCOMPILER_COPY_DEFAULT(Ref); - - public: - explicit Ref(T cls, const Bool& strong = false) - : m_Class(&cls), m_Strong(strong) - { - } - - Ref& operator=(T ref) - { - *m_Class = ref; - return *this; - } - - public: - T* operator->() const - { - return m_Class; - } - - T& Leak() - { - return *m_Class; - } - - T operator*() - { - return *m_Class; - } - - Bool IsStrong() const - { - return m_Strong; - } - - operator bool() - { - return *m_Class; - } - - private: - T* m_Class{nullptr}; - Bool m_Strong{false}; - }; - - // @author EL Mahrouss Amlal - // @brief Non null Reference holder class, refers to a pointer of data in static memory. - template - class NonNullRef final - { - public: - explicit NonNullRef() = delete; - - explicit NonNullRef(T* ref) - : m_Ref(ref, true) - { - } - - Ref& operator->() - { - MUST_PASS(m_Ref); - return m_Ref; - } - - NonNullRef& operator=(const NonNullRef& ref) = delete; - NonNullRef(const NonNullRef& ref) = default; - - private: - Ref m_Ref{nullptr}; - }; -} // namespace LibCompiler -- cgit v1.2.3