aboutsummaryrefslogtreecommitdiffhomepage
path: root/tdutils/td/utils/fixed_vector.h
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2022-02-18 23:04:25 +0300
committerlevlam <levlam@telegram.org>2022-02-18 23:04:25 +0300
commitae3854d97c7e983e9560f19ca144b5a89ca5348e (patch)
treeec1d0af212ea606130eea08a2798de63aa1ef4fc /tdutils/td/utils/fixed_vector.h
parentb5cf85d6e2be8cf10dc06df4ee63a69cbf23cf91 (diff)
Various fixes.
Diffstat (limited to 'tdutils/td/utils/fixed_vector.h')
-rw-r--r--tdutils/td/utils/fixed_vector.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/tdutils/td/utils/fixed_vector.h b/tdutils/td/utils/fixed_vector.h
index ccb05192e..0ee720d3c 100644
--- a/tdutils/td/utils/fixed_vector.h
+++ b/tdutils/td/utils/fixed_vector.h
@@ -1,7 +1,17 @@
+//
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
#pragma once
+
#include "td/utils/common.h"
+#include <utility>
+
namespace td {
+
template <class T>
class fixed_vector {
public:
@@ -20,12 +30,17 @@ class fixed_vector {
~fixed_vector() {
delete[] ptr_;
}
+
+ using iterator = T *;
+ using const_iterator = const T *;
+
T &operator[](size_t i) {
return ptr_[i];
}
const T &operator[](size_t i) const {
return ptr_[i];
}
+
T *begin() {
return ptr_;
}
@@ -38,14 +53,14 @@ class fixed_vector {
const T *end() const {
return ptr_ + size_;
}
+
bool empty() const {
return size() == 0;
}
size_t size() const {
return size_;
}
- using iterator = T *;
- using const_iterator = const T *;
+
void swap(fixed_vector<T> &other) {
std::swap(ptr_, other.ptr_);
std::swap(size_, other.size_);
@@ -55,4 +70,5 @@ class fixed_vector {
T *ptr_{};
size_t size_{0};
};
-} // namespace td \ No newline at end of file
+
+} // namespace td