#ifndef CORE_FXCRT_FIXED_SIZE_DATA_VECTOR_H_
#define CORE_FXCRT_FIXED_SIZE_DATA_VECTOR_H_
#include <stddef.h>
#include <memory>
#include <utility>
#include "core/fxcrt/check_op.h"
#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/fx_memory_wrappers.h"
#include "core/fxcrt/span.h"
namespace fxcrt {
template <typename T,
typename = std::enable_if_t<std::is_arithmetic<T>::value ||
std::is_enum<T>::value ||
IsFXDataPartitionException<T>::value>>
class FixedSizeDataVector {
public:
FixedSizeDataVector() = default;
static FixedSizeDataVector Uninit(size_t size) { … }
static FixedSizeDataVector TryUninit(size_t size) { … }
static FixedSizeDataVector Zeroed(size_t size) { … }
static FixedSizeDataVector TryZeroed(size_t size) { … }
static FixedSizeDataVector TruncatedFrom(FixedSizeDataVector&& that,
size_t new_size) { … }
FixedSizeDataVector(const FixedSizeDataVector&) = delete;
FixedSizeDataVector& operator=(const FixedSizeDataVector&) = delete;
FixedSizeDataVector(FixedSizeDataVector<T>&& that) noexcept
: … { … }
FixedSizeDataVector& operator=(FixedSizeDataVector<T>&& that) noexcept { … }
~FixedSizeDataVector() = default;
bool empty() const { … }
size_t size() const { … }
operator pdfium::span<T>() { return span(); }
operator pdfium::span<const T>() const { return span(); }
pdfium::span<T> span() { … }
pdfium::span<const T> span() const { … }
pdfium::span<T> subspan(size_t offset,
size_t count = pdfium::dynamic_extent) { … }
pdfium::span<const T> subspan(size_t offset,
size_t count = pdfium::dynamic_extent) const { … }
pdfium::span<T> first(size_t count) { … }
pdfium::span<const T> first(size_t count) const { … }
pdfium::span<T> last(size_t count) { … }
pdfium::span<const T> last(size_t count) const { … }
private:
UNSAFE_BUFFER_USAGE FixedSizeDataVector(T* ptr, size_t size)
: … { … }
std::unique_ptr<T, FxFreeDeleter> data_;
size_t size_ = 0;
};
}
FixedSizeDataVector;
#endif