Open C++ Libraries.org develop
Loading...
Searching...
No Matches
smart_ptr.hpp
1// SPDX-License-Identifier: BSL-1.0
2// Copyright 2025-2026, Amlal El Mahrouss (amlal@nekernel.org)
3// Distributed under the Boost Software License, Version 1.0. (See accompanying
4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5// Official repository: https://github.com/open-cpp-libraries/core
6
7#ifndef OCL_SMART_PTR
8#define OCL_SMART_PTR
9
10#include <boost/core/null_deleter.hpp>
11#include <ocl/detail/config.hpp>
12#include <ocl/tracked_ptr.hpp>
13#include <memory>
14
16
18{
19
20 template <class Type, class Del = std::default_delete<Type>>
21 using unique_ptr = std::unique_ptr<Type, Del>;
22
23 template <class Type>
24 using shared_ptr = std::shared_ptr<Type>;
25
26 template <class Type>
27 using weak_ptr = std::weak_ptr<Type>;
28
30 template <class Type>
31 inline auto delete_ptr(Type* object) -> shared_ptr<Type>
32 {
33 return shared_ptr<Type>{object, ::boost::null_deleter{}};
34 }
35
36} // namespace ocl
37
38#endif // ifndef OCL_SMART_PTR
Support for the smart pointer file for the OCL.
Definition smart_ptr.hpp:18
auto delete_ptr(Type *object) -> shared_ptr< Type >
Constructs a delete_ptr, that is, a pointer that isn't deleted from the heap.
Definition smart_ptr.hpp:31