#pragma once #include "fwd.h" #include "reserve.h" #include #include #include #ifdef _YNDX_LIBCXX_ENABLE_VECTOR_POD_RESIZE_UNINITIALIZED #include #endif template class TVector: public std::vector> { public: using TBase = std::vector>; using TSelf = TVector; using size_type = typename TBase::size_type; inline TVector() : TBase() { } inline TVector(const typename TBase::allocator_type& a) : TBase(a) { } inline explicit TVector(::NDetail::TReserveTag rt) : TBase() { this->reserve(rt.Capacity); } inline explicit TVector(::NDetail::TReserveTag rt, const typename TBase::allocator_type& a) : TBase(a) { this->reserve(rt.Capacity); } inline explicit TVector(size_type count) : TBase(count) { } inline explicit TVector(size_type count, const typename TBase::allocator_type& a) : TBase(count, a) { } inline TVector(size_type count, const T& val) : TBase(count, val) { } inline TVector(size_type count, const T& val, const typename TBase::allocator_type& a) : TBase(count, val, a) { } inline TVector(std::initializer_list il) : TBase(il) { } inline TVector(std::initializer_list il, const typename TBase::allocator_type& a) : TBase(il, a) { } inline TVector(const TSelf& src) : TBase(src) { } inline TVector(TSelf&& src) noexcept : TBase(std::move(src)) { } template inline TVector(TIter first, TIter last) : TBase(first, last) { } inline TSelf& operator=(const TSelf& src) { TBase::operator=(src); return *this; } inline TSelf& operator=(TSelf&& src) noexcept { TBase::operator=(std::move(src)); return *this; } inline TSelf& operator=(std::initializer_list il) { this->assign(il.begin(), il.end()); return *this; } inline explicit operator bool() const noexcept { return !this->empty(); } Y_PURE_FUNCTION inline bool empty() const noexcept { return TBase::empty(); } inline yssize_t ysize() const noexcept { return static_cast(TBase::size()); } void yresize(size_type newSize) { #if defined(_YNDX_LIBCXX_ENABLE_VECTOR_POD_RESIZE_UNINITIALIZED) && !defined(__CUDACC__) if constexpr (std::is_standard_layout_v && std::is_trivial_v) { TBase::resize_uninitialized(newSize); return; } #endif TBase::resize(newSize); } inline void crop(size_type size) { if (this->size() > size) { this->erase(this->begin() + size, this->end()); } } };