summaryrefslogtreecommitdiffhomepage
path: root/include/ocl/smart_ptr.hpp
blob: 489f277c30608ddf7631d1357cafe45b9fb2b0f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
 * 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_SMART_PTR
#define __OCL_SMART_PTR

#include <boost/core/null_deleter.hpp>
#include <ocl/detail/config.hpp>
#include <ocl/tracked_ptr.hpp>
#include <memory>

namespace ocl
{
	template <class T, class Del = std::default_delete<T>>
	using unique_ptr = std::unique_ptr<T, Del>;

	template <class T>
	using shared_ptr = std::shared_ptr<T>;

	/// @brief Constructs a `delete_ptr`, that is, a pointer that isn't deleted from the heap.
	template <class T>
	inline auto delete_ptr(T* object) -> auto
	{
		return shared_ptr<T>{object, boost::null_deleter{}};
	}
} // namespace ocl

#endif // ifndef __OCL_SMART_PTR