diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2026-01-13 17:55:52 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2026-01-13 17:55:52 +0100 |
| commit | d42491e025977f8207d36f3bc972db8a3d1dc775 (patch) | |
| tree | add9b9962301b2000493e9cf32e310c96902f871 | |
| parent | 149a5998b5ec6f825998a27a305d972022271888 (diff) | |
chore: release prep for OCL.Core.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
| -rw-r--r-- | include/ocl/allocator_op.hpp | 12 | ||||
| -rw-r--r-- | include/ocl/equiv.hpp | 5 | ||||
| -rw-r--r-- | include/ocl/io.hpp | 2 | ||||
| -rw-r--r-- | include/ocl/print.hpp | 9 | ||||
| -rw-r--r-- | include/ocl/smart_ptr.hpp | 3 | ||||
| -rw-r--r-- | include/ocl/tracked_ptr.hpp | 35 |
6 files changed, 43 insertions, 23 deletions
diff --git a/include/ocl/allocator_op.hpp b/include/ocl/allocator_op.hpp index d6f5a5e..d3506e0 100644 --- a/include/ocl/allocator_op.hpp +++ b/include/ocl/allocator_op.hpp @@ -40,7 +40,7 @@ namespace ocl }; template <typename type> - struct global_array_delete_op final + struct global_delete_op final { using pointer_type = type*; using const_pointer_type = const type*; @@ -51,6 +51,10 @@ namespace ocl } }; + /// \brief Backwards compat. alias of global_new_op. + template <typename type> + using global_array_delete_op = global_new_op<type>; + /// \brief Allocator operations structure. Takes care of memory mgmt within a pool. template <typename ret_type, typename allocator_new, typename allocator_delete> class allocator_op @@ -63,12 +67,12 @@ namespace ocl allocator_op(const allocator_op&) = delete; template <typename... var_type> - auto construct_var(var_type... args) + auto construct_var(var_type&&... args) { return std::shared_ptr<ret_type>(allocator_new{}.template var_alloc<var_type...>(std::forward<var_type...>(args)...), allocator_delete{}); } - template <size_t N> + template <std::size_t N> auto construct_array() { return std::shared_ptr<ret_type>(allocator_new{}.template array_alloc<N>(), allocator_delete{}); @@ -76,7 +80,7 @@ namespace ocl }; template <typename type> - using allocator = allocator_op<type, global_new_op<type>, global_array_delete_op<type>>; + using allocator = allocator_op<type, global_new_op<type>, global_delete_op<type>>; } // namespace ocl diff --git a/include/ocl/equiv.hpp b/include/ocl/equiv.hpp index 892fe5c..7e14523 100644 --- a/include/ocl/equiv.hpp +++ b/include/ocl/equiv.hpp @@ -46,6 +46,11 @@ namespace ocl static constexpr auto value = true; }; + /// \brief alias equiv_to to boolean type. + template <typename T> + using equiv_to_bool = equiv_to<bool, T>; + + } // namespace ocl #endif diff --git a/include/ocl/io.hpp b/include/ocl/io.hpp index f5cf2b5..6d467e0 100644 --- a/include/ocl/io.hpp +++ b/include/ocl/io.hpp @@ -17,7 +17,7 @@ #define console_io_out ::ocl::io::void_cout #define console_io_in ::ocl::io::void_cin -#warning The OCL doesnt define IO streams in a freestanding host. +#warning The OCL doesnt define IO streams in freestanding mode. namespace ocl::io { diff --git a/include/ocl/print.hpp b/include/ocl/print.hpp index 374a151..1483ed6 100644 --- a/include/ocl/print.hpp +++ b/include/ocl/print.hpp @@ -64,10 +64,15 @@ namespace ocl::io inline void lf() noexcept { #ifdef OCL_USE_CRLF_ENDINGS - print("\r\n"); + if (!is_stdio_sync) + print("\r\n"); #else - print("\n"); + if (!is_stdio_sync()) + print("\n"); #endif + + if (is_stdio_sync()) + console_io_out << std::endl; } template <typename... T> diff --git a/include/ocl/smart_ptr.hpp b/include/ocl/smart_ptr.hpp index 23400e2..c144361 100644 --- a/include/ocl/smart_ptr.hpp +++ b/include/ocl/smart_ptr.hpp @@ -20,6 +20,9 @@ namespace ocl template <class Type> using shared_ptr = std::shared_ptr<Type>; + template <class Type> + using weak_ptr = std::weak_ptr<Type>; + /// @brief Constructs a `delete_ptr`, that is, a pointer that isn't deleted from the heap. template <class Type> inline auto delete_ptr(Type* object) -> shared_ptr<Type> diff --git a/include/ocl/tracked_ptr.hpp b/include/ocl/tracked_ptr.hpp index 6b82a5d..0f32b93 100644 --- a/include/ocl/tracked_ptr.hpp +++ b/include/ocl/tracked_ptr.hpp @@ -6,6 +6,7 @@ #ifndef __OCL_TRACKED_PTR #define __OCL_TRACKED_PTR +#include "boost/assert/source_location.hpp" #include <ocl/detail/config.hpp> #include <atomic> #include <stdexcept> @@ -31,10 +32,10 @@ namespace ocl using pointer_type = Type*; using type = Type; - template <typename... U> - void retain(pointer_type& ptr, U&&... args) + template <typename... Args> + void retain(pointer_type& ptr, Args&&... args) { - ptr = new type(std::forward<U>(args)...); + ptr = new type(std::forward<Args>(args)...); if (ptr) { @@ -82,21 +83,21 @@ namespace ocl return allocator_; } - template <typename... U> - pointer_type retain(U&&... args) + template <typename... Args> + pointer_type retain(Args&&... args) { pointer_type ptr = nullptr; - allocator_.retain(ptr, std::forward<U>(args)...); + allocator_.retain(ptr, std::forward<Args>(args)...); return ptr; } - template <typename... U> - [[maybe_unused]] pointer_type must_retain(U&&... args) + template <typename... Args> + [[maybe_unused]] pointer_type must_retain(Args&&... args) { try { - return this->retain(std::forward<U>(args)...); + return this->retain(std::forward<Args>(args)...); } catch (...) { @@ -113,14 +114,16 @@ namespace ocl template <typename Type, typename Mgr = tracked_mgr<Type>> class tracked_ptr { - Mgr m_mgr_; + using manager = Mgr; + + manager mgr_; public: - template <typename... U> - tracked_ptr(U&&... args) + template <typename... Args> + tracked_ptr(Args&&... args) : ptr_(nullptr) { - ptr_ = m_mgr_.retain(std::forward<U>(args)...); + ptr_ = mgr_.retain(std::forward<Args>(args)...); } virtual ~tracked_ptr() noexcept @@ -136,7 +139,7 @@ namespace ocl using type = Type; using reference_type = Type&; using const_reference_type = const Type&; - using manager_type = tracked_mgr<Type>; + using manager_type = tracked_mgr<manager>; using pointer = pointer_type; using reference = reference_type; @@ -144,7 +147,7 @@ namespace ocl { if (ptr_) { - m_mgr_.dispose(ptr_); + mgr_.dispose(ptr_); } } @@ -217,7 +220,7 @@ namespace ocl { using tracked_error = std::runtime_error; - inline void throw_tracked_error(const boost::string_view& loc = BOOST_CURRENT_LOCATION.to_string()) + inline void throw_tracked_error(const boost::source_location& loc = BOOST_CURRENT_LOCATION) { throw tracked_error(loc.to_string()); } |
