tgbotxx  1.1.6.9
Telegram Bot C++ Library
Ptr.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <memory>
3 
4 namespace tgbotxx {
5  template<typename T>
6  using Ptr = std::shared_ptr<T>;
7 
8  template<typename T>
9  using CPtr = const std::shared_ptr<T>;
10 
11  template<typename T>
12  using PtrC = std::shared_ptr<const T>;
13 
14  template<typename T>
15  using CPtrC = const std::shared_ptr<const T>;
16 
17 
18  template<typename T>
19  struct isPtr : std::false_type {};
20  template<typename T>
21  struct isPtr<Ptr<T>> : std::true_type {};
22  template<typename T>
23  struct isPtr<CPtr<T>> : std::true_type {};
24  template<typename T>
25  struct isPtr<PtrC<T>> : std::true_type {};
26  template<typename T>
27  struct isPtr<CPtrC<T>> : std::true_type {};
28 
29 
30  template<typename T, typename... Args>
31  [[nodiscard]] static Ptr<T> makePtr(Args&&...args) {
32  return std::make_shared<T>(std::forward<Args>(args)...);
33  }
34 }
Definition: Api.hpp:14
std::shared_ptr< const T > PtrC
Definition: Ptr.hpp:12
std::shared_ptr< T > Ptr
Definition: Ptr.hpp:6
const std::shared_ptr< T > CPtr
Definition: Ptr.hpp:9
const std::shared_ptr< const T > CPtrC
Definition: Ptr.hpp:15
static Ptr< T > makePtr(Args &&...args)
Definition: Ptr.hpp:31