MCPcopy Create free account
hub / github.com/apache/arrow / StaticVectorImpl

Class StaticVectorImpl

cpp/src/arrow/util/small_vector.h:209–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207
208template <typename T, size_t N, typename Storage>
209class StaticVectorImpl {
210 private:
211 Storage storage_;
212
213 T* data_ptr() { return storage_.storage_ptr()->get(); }
214
215 constexpr const T* const_data_ptr() const {
216 return storage_.const_storage_ptr()->get();
217 }
218
219 public:
220 using size_type = size_t;
221 using difference_type = ptrdiff_t;
222 using value_type = T;
223 using pointer = T*;
224 using const_pointer = const T*;
225 using reference = T&;
226 using const_reference = const T&;
227 using iterator = T*;
228 using const_iterator = const T*;
229 using reverse_iterator = std::reverse_iterator<iterator>;
230 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
231
232 constexpr StaticVectorImpl() noexcept = default;
233
234 // Move and copy constructors
235 StaticVectorImpl(StaticVectorImpl&& other) noexcept {
236 storage_.move_construct(std::move(other.storage_));
237 }
238
239 StaticVectorImpl& operator=(StaticVectorImpl&& other) noexcept {
240 if (ARROW_PREDICT_TRUE(&other != this)) {
241 // TODO move_assign?
242 storage_.destroy();
243 storage_.move_construct(std::move(other.storage_));
244 }
245 return *this;
246 }
247
248 StaticVectorImpl(const StaticVectorImpl& other) {
249 init_by_copying(other.storage_.size_, other.const_data_ptr());
250 }
251
252 StaticVectorImpl& operator=(const StaticVectorImpl& other) noexcept {
253 if (ARROW_PREDICT_TRUE(&other != this)) {
254 assign_by_copying(other.storage_.size_, other.data());
255 }
256 return *this;
257 }
258
259 // Automatic conversion from std::vector<T>, for convenience
260 StaticVectorImpl(const std::vector<T>& other) { // NOLINT: explicit
261 init_by_copying(other.size(), other.data());
262 }
263
264 StaticVectorImpl(std::vector<T>&& other) noexcept { // NOLINT: explicit
265 init_by_moving(other.size(), other.data());
266 }

Callers

nothing calls this directly

Calls 4

destroyMethod · 0.45
move_constructMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected