summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--examples/.keep0
-rw-r--r--include/ocl/option.hpp5
-rw-r--r--include/ocl/smart_ptr.hpp19
-rw-r--r--include/ocl/tracked_ptr.hpp5
4 files changed, 20 insertions, 9 deletions
diff --git a/examples/.keep b/examples/.keep
deleted file mode 100644
index e69de29..0000000
--- a/examples/.keep
+++ /dev/null
diff --git a/include/ocl/option.hpp b/include/ocl/option.hpp
index e114b43..9286ef9 100644
--- a/include/ocl/option.hpp
+++ b/include/ocl/option.hpp
@@ -12,7 +12,7 @@
namespace ocl
{
- enum class return_type
+ enum struct return_type
{
invalid = 0,
okay = 100,
@@ -50,8 +50,7 @@ namespace ocl
{
if (ret_ == return_type::err)
{
- ErrorHandler err_handler;
- err_handler(input ? input : "option::error");
+ ErrorHandler{}(input ? input : "option::error");
}
return *this;
diff --git a/include/ocl/smart_ptr.hpp b/include/ocl/smart_ptr.hpp
index adab5aa..f8b7108 100644
--- a/include/ocl/smart_ptr.hpp
+++ b/include/ocl/smart_ptr.hpp
@@ -1,13 +1,14 @@
/*
- * File: unique_pr.hpp
- * Purpose: Unique Pointer helpers.
+ * File: smart_ptr.hpp
+ * Purpose: Smart Pointer helpers.
* Author: Amlal El Mahrouss (amlal@nekernel.org)
* Copyright 2025, Amlal El Mahrouss, Licensed under the Boost Software License. Licensed under the BSL 1.0 license
*/
-#ifndef __OCL_UNIQUE_PTR
-#define __OCL_UNIQUE_PTR
+#ifndef __OCL_SMART_PTR
+#define __OCL_SMART_PTR
+#include <boost/core/null_deleter.hpp>
#include <ocl/detail/config.hpp>
#include <ocl/tracked_ptr.hpp>
#include <memory>
@@ -16,6 +17,14 @@ namespace ocl
{
template <class T, class Del>
using unique_ptr = std::unique_ptr<T, Del>;
+
+ template<class T, class _Deleter>
+ inline auto delete_ptr(T& obj) -> auto { return std::shared_ptr<T>{obj, _Deleter()}; }
+
+ /// @brief Constructs a `null_ptr`, that is, a pointer that isn't deleted from the heap.
+ template<class T>
+ inline auto null_deleter(T& obj) -> auto { return delete_ptr<T, boost::null_deleter>(obj); }
+
}
-#endif // ifndef __OCL_UNIQUE_PTR \ No newline at end of file
+#endif // ifndef __OCL_SMART_PTR \ No newline at end of file
diff --git a/include/ocl/tracked_ptr.hpp b/include/ocl/tracked_ptr.hpp
index 5a1b94e..23ced29 100644
--- a/include/ocl/tracked_ptr.hpp
+++ b/include/ocl/tracked_ptr.hpp
@@ -5,7 +5,8 @@
* Copyright 2025, Amlal El Mahrouss, licensed under the Boost Software License.
*/
-#pragma once
+#ifndef __OCL_TRACKED_PTR
+#define __OCL_TRACKED_PTR
#include <exception>
#include <ocl/detail/config.hpp>
@@ -233,3 +234,5 @@ namespace ocl
}
}
} // namespace ocl
+
+#endif // ifndef __OCL_TRACKED_PTR \ No newline at end of file