1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
/*
Copyright (c) 2020-2023, Intel Corporation
SPDX-License-Identifier: BSD-3-Clause
*/
/** @file array.hpp
@brief minimal implementation of std::array
This header is added to avoid additional dependency on C++ library
for builtins-c-cpu.cpp file.
*/
namespace notstd {
template <typename T, int sizeImpl> struct array {
T dataImpl[sizeImpl];
using value_type = T;
using reference = T &;
using const_reference = const T &;
using pointer = T *;
using const_pointer = const T *;
using iterator = pointer;
using const_iterator = const_pointer;
using size_type = int;
size_type size() const noexcept { return sizeImpl; }
pointer data() noexcept { return &dataImpl[0]; }
const_pointer data() const noexcept { return &dataImpl[0]; }
iterator begin() noexcept { return data(); }
const_iterator begin() const noexcept { return data(); }
iterator end() noexcept { return data() + size(); }
const_iterator end() const noexcept { return data() + size(); }
const_reference operator[](int idx) const noexcept { return dataImpl[idx]; }
reference operator[](int idx) noexcept { return dataImpl[idx]; }
};
} // namespace notstd
|