15 #include "cpp_utils/aligned_vector.hpp" 25 template <
typename T,
typename Alloc>
32 resize_impl(rhs.size,
false);
34 for (
size_t i = 0; i < size; ++i) {
35 _data[i] = rhs._data[i];
46 resize_impl(rhs.size,
false);
50 for (
size_t i = 0; i < size; ++i) {
51 _data[i] = rhs._data[i];
75 void resize(
size_t n) {
79 T& operator[](
size_t i) {
83 const T& operator[](
size_t i)
const {
91 const T* data()
const {
99 if constexpr (!std::is_trivially_default_constructible_v<T>) {
100 for (
size_t i = 0; i < size; ++i) {
105 allocator.deallocate(_data, size);
111 void resize_impl(
size_t n,
bool copy =
true) {
112 auto* new_data = allocator.allocate(n);
115 if constexpr (!std::is_trivially_default_constructible_v<T>) {
116 new (new_data) T[n]();
120 if constexpr (std::is_trivially_default_constructible_v<T>) {
121 std::fill_n(new_data, n, T());
125 for (
size_t i = 0; i < size && i < n; ++i) {
126 new_data[i] = _data[i];
141 template <
typename T, std::
size_t A>
143 using type = std::vector<T, cpp::aligned_allocator<T, A>>;
146 template <std::
size_t A>
151 template <
typename T, std::
size_t A>
152 using aligned_vector =
typename aligned_vector_impl<T, A>::type;
Root namespace for the ETL library.
Definition: adapter.hpp:15
A simple std::vector to work with bool.
Definition: aligned_vector.hpp:26
Definition: aligned_vector.hpp:142