diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/containers/stack_array/stack_array.h | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/containers/stack_array/stack_array.h')
-rw-r--r-- | library/cpp/containers/stack_array/stack_array.h | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/library/cpp/containers/stack_array/stack_array.h b/library/cpp/containers/stack_array/stack_array.h index 28e49bfc3c..105189de06 100644 --- a/library/cpp/containers/stack_array/stack_array.h +++ b/library/cpp/containers/stack_array/stack_array.h @@ -1,11 +1,11 @@ -#pragma once - -#include "range_ops.h" - +#pragma once + +#include "range_ops.h" + #include <util/generic/array_ref.h> #include <util/system/defaults.h> /* For alloca. */ - -namespace NStackArray { + +namespace NStackArray { /** * A stack-allocated array. Should be used instead of � variable length * arrays that are not part of C++ standard. @@ -21,20 +21,20 @@ namespace NStackArray { * * Note that it is generally a *VERY BAD* idea to use this in inline methods * as those might be called from a loop, and then stack overflow is in the cards. - */ - template <class T> + */ + template <class T> class TStackArray: public TArrayRef<T> { - public: - inline TStackArray(void* data, size_t len) + public: + inline TStackArray(void* data, size_t len) : TArrayRef<T>((T*)data, len) - { + { NRangeOps::InitializeRange(this->begin(), this->end()); - } - + } + inline ~TStackArray() { NRangeOps::DestroyRange(this->begin(), this->end()); - } - }; -} - -#define ALLOC_ON_STACK(type, n) alloca(sizeof(type) * (n)), (n) + } + }; +} + +#define ALLOC_ON_STACK(type, n) alloca(sizeof(type) * (n)), (n) |