From d42491e025977f8207d36f3bc972db8a3d1dc775 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 13 Jan 2026 17:55:52 +0100 Subject: chore: release prep for OCL.Core. Signed-off-by: Amlal El Mahrouss --- include/ocl/allocator_op.hpp | 12 ++++++++---- include/ocl/equiv.hpp | 5 +++++ include/ocl/io.hpp | 2 +- include/ocl/print.hpp | 9 +++++++-- include/ocl/smart_ptr.hpp | 3 +++ include/ocl/tracked_ptr.hpp | 35 +++++++++++++++++++---------------- 6 files changed, 43 insertions(+), 23 deletions(-) (limited to 'include') 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 - 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 + using global_array_delete_op = global_new_op; + /// \brief Allocator operations structure. Takes care of memory mgmt within a pool. template class allocator_op @@ -63,12 +67,12 @@ namespace ocl allocator_op(const allocator_op&) = delete; template - auto construct_var(var_type... args) + auto construct_var(var_type&&... args) { return std::shared_ptr(allocator_new{}.template var_alloc(std::forward(args)...), allocator_delete{}); } - template + template auto construct_array() { return std::shared_ptr(allocator_new{}.template array_alloc(), allocator_delete{}); @@ -76,7 +80,7 @@ namespace ocl }; template - using allocator = allocator_op, global_array_delete_op>; + using allocator = allocator_op, global_delete_op>; } // 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 + using equiv_to_bool = equiv_to; + + } // 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 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 using shared_ptr = std::shared_ptr; + template + using weak_ptr = std::weak_ptr; + /// @brief Constructs a `delete_ptr`, that is, a pointer that isn't deleted from the heap. template inline auto delete_ptr(Type* object) -> shared_ptr 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 #include #include @@ -31,10 +32,10 @@ namespace ocl using pointer_type = Type*; using type = Type; - template - void retain(pointer_type& ptr, U&&... args) + template + void retain(pointer_type& ptr, Args&&... args) { - ptr = new type(std::forward(args)...); + ptr = new type(std::forward(args)...); if (ptr) { @@ -82,21 +83,21 @@ namespace ocl return allocator_; } - template - pointer_type retain(U&&... args) + template + pointer_type retain(Args&&... args) { pointer_type ptr = nullptr; - allocator_.retain(ptr, std::forward(args)...); + allocator_.retain(ptr, std::forward(args)...); return ptr; } - template - [[maybe_unused]] pointer_type must_retain(U&&... args) + template + [[maybe_unused]] pointer_type must_retain(Args&&... args) { try { - return this->retain(std::forward(args)...); + return this->retain(std::forward(args)...); } catch (...) { @@ -113,14 +114,16 @@ namespace ocl template > class tracked_ptr { - Mgr m_mgr_; + using manager = Mgr; + + manager mgr_; public: - template - tracked_ptr(U&&... args) + template + tracked_ptr(Args&&... args) : ptr_(nullptr) { - ptr_ = m_mgr_.retain(std::forward(args)...); + ptr_ = mgr_.retain(std::forward(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; + using manager_type = tracked_mgr; 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()); } -- cgit v1.2.3