blob: 4bdff42114344a0cb7caa7d8d4832a11283aa970 (
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 Type, class Del = std::default_delete<Type>>
using unique_ptr = std::unique_ptr<Type, Del>;
template <class Type>
using shared_ptr = std::shared_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>
{
return shared_ptr<Type>{object, boost::null_deleter{}};
}
} // namespace ocl
#endif // ifndef __OCL_SMART_PTR
|