diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-10 19:51:51 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-10 19:51:51 +0100 |
| commit | c62d8578cc50f20fe65624afdf642c1763b3547d (patch) | |
| tree | f588e34d36921acf4818cdf246af18a97e63525e /include | |
| parent | f7840112f468367feb9aee8cbc9146d74a1e87e0 (diff) | |
feat: new `smart_ptr.hpp` API, new `smart_socket.hpp` API.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/ocl/smart_ptr.hpp | 10 | ||||
| -rw-r--r-- | include/ocl/smart_socket.hpp | 15 |
2 files changed, 20 insertions, 5 deletions
diff --git a/include/ocl/smart_ptr.hpp b/include/ocl/smart_ptr.hpp index f8b7108..333e460 100644 --- a/include/ocl/smart_ptr.hpp +++ b/include/ocl/smart_ptr.hpp @@ -15,15 +15,15 @@ namespace ocl { - template <class T, class Del> + template <class T, class Del = std::default_delete<T>> 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()}; } + template <class T> + using shared_ptr = std::shared_ptr<T>; - /// @brief Constructs a `null_ptr`, that is, a pointer that isn't deleted from the heap. + /// @brief Constructs a `delete_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); } + inline auto delete_ptr(T* object) -> auto { return shared_ptr<T>{ object, boost::null_deleter{}}; } } diff --git a/include/ocl/smart_socket.hpp b/include/ocl/smart_socket.hpp new file mode 100644 index 0000000..cba177c --- /dev/null +++ b/include/ocl/smart_socket.hpp @@ -0,0 +1,15 @@ +/* + * File: smart_socket.hpp + * Purpose: Smart Socket 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_SMART_SOCKET +#define __OCL_SMART_SOCKET + +#include <ocl/detail/config.hpp> +#include <ocl/unique_socket.hpp> +#include <boost/asio.hpp> + +#endif // __OCL_SMART_SOCKET
\ No newline at end of file |
