Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/intgemm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'aligned.h')
-rw-r--r--aligned.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/aligned.h b/aligned.h
index 44889d1..83915a1 100644
--- a/aligned.h
+++ b/aligned.h
@@ -19,4 +19,17 @@ template <class T> T* AlignedArray(std::size_t size) {
return static_cast<T*>(aligned_alloc(64, size * sizeof(T)));
}
+template <class T> class AlignedVector {
+ public:
+ explicit AlignedVector(std::size_t size) : mem_(AlignedArray<T>(size)) {}
+
+ T &operator[](std::size_t offset) { return mem_.get()[offset]; }
+ const T &operator[](std::size_t offset) const { return mem_.get()[offset]; }
+
+ T *get() { return mem_.get(); }
+ const T *get() const { return mem_.get(); }
+ private:
+ free_ptr<T> mem_;
+};
+
} // namespace intgemm