17 #include <type_traits> 22 class TlStorerCalcLength;
26 class TlStorerToString;
36 virtual std::int32_t
get_id()
const = 0;
42 virtual void store(TlStorerUnsafe &s)
const {
49 virtual void store(TlStorerCalcLength &s)
const {
57 virtual void store(TlStorerToString &s,
const char *field_name)
const = 0;
97 using element_type = T;
99 unique_ptr() noexcept = default;
100 unique_ptr(const unique_ptr &) = delete;
101 unique_ptr &operator=(const unique_ptr &) = delete;
102 unique_ptr(unique_ptr &&other) noexcept : ptr_(other.release()) {
104 unique_ptr &operator=(unique_ptr &&other) noexcept {
105 reset(other.release());
112 unique_ptr(std::nullptr_t) noexcept {
114 explicit unique_ptr(T *ptr) noexcept : ptr_(ptr) {
116 template <class S, class = typename std::enable_if<std::is_base_of<T, S>::value>::type>
117 unique_ptr(unique_ptr<S> &&other) noexcept : ptr_(static_cast<S *>(other.release())) {
119 template <class S, class = typename std::enable_if<std::is_base_of<T, S>::value>::type>
120 unique_ptr &operator=(unique_ptr<S> &&other) noexcept {
121 reset(static_cast<T *>(other.release()));
124 void reset(T *new_ptr =
nullptr) noexcept {
125 static_assert(
sizeof(T) > 0,
"Can't destroy unique_ptr with incomplete type");
129 T *release() noexcept {
137 const T *get() const noexcept {
140 T *operator->() noexcept {
143 const T *operator->() const noexcept {
146 T &operator*() noexcept {
149 const T &operator*() const noexcept {
152 explicit operator bool() const noexcept {
153 return ptr_ !=
nullptr;
161 bool operator==(std::nullptr_t,
const unique_ptr<T> &p) {
165 bool operator==(
const unique_ptr<T> &p, std::nullptr_t) {
169 bool operator!=(std::nullptr_t,
const unique_ptr<T> &p) {
170 return static_cast<bool>(p);
173 bool operator!=(
const unique_ptr<T> &p, std::nullptr_t) {
174 return static_cast<bool>(p);
183 template <
class Type>
201 template <
class Type,
class... Args>
250 template <
class ToT,
class FromT>
258 template <
class ToT,
class FromT>
virtual void store(TlStorerCalcLength &s) const
Definition: TlObject.h:49
tl_object_ptr< Type > make_tl_object(Args &&...args)
Definition: TlObject.h:202
TlObject & operator=(const TlObject &)=delete
tl_object_ptr< ToT > move_tl_object_as(tl_object_ptr< FromT > &from)
Definition: TlObject.h:251
virtual std::int32_t get_id() const =0
tl::unique_ptr< Type > tl_object_ptr
Definition: TlObject.h:184
Definition: TlObject.h:31
virtual void store(TlStorerUnsafe &s) const
Definition: TlObject.h:42
virtual ~TlObject()=default