sculpto
smart_ptr.h
Go to the documentation of this file.
1/*!****************************************************************//*!*
2 * \file shared.h
3 * \brief Smart pointers implementatino module.
4 *
5 * \author Sabitov Kirill
6 * \date 22 June 2022
7 *********************************************************************/
8
9#pragma once
10
11namespace scl
12{
14 template<typename T>
15 using shared = std::shared_ptr<T>;
16
17 template<typename T, typename... Args>
18 constexpr shared<T> CreateShared(Args &&... args)
19 {
20 return std::make_shared<T>(std::forward<Args>(args)...);
21 }
22
24 template<typename T>
25 using unique = std::unique_ptr<T>;
26
27 template<typename T, typename... Args>
28 constexpr unique<T> CreateUnique(Args &&... args)
29 {
30 return std::make_unique<T>(std::forward<Args>(args)...);
31 }
32
34 template<typename T>
35 using weak = std::weak_ptr<T>;
36}
Definition: base.h:33
std::shared_ptr< T > shared
Definition: smart_ptr.h:15
std::weak_ptr< T > weak
Definition: smart_ptr.h:35
std::unique_ptr< T > unique
Definition: smart_ptr.h:25
constexpr shared< T > CreateShared(Args &&... args)
Definition: smart_ptr.h:18
constexpr unique< T > CreateUnique(Args &&... args)
Definition: smart_ptr.h:28