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

Class AlignedStorage

cpp/src/arrow/util/aligned_storage.h:31–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29
30template <typename T>
31class AlignedStorage {
32 public:
33 static constexpr bool can_memcpy = std::is_trivial<T>::value;
34
35 constexpr T* get() noexcept {
36 return arrow::internal::launder(reinterpret_cast<T*>(&data_));
37 }
38
39 constexpr const T* get() const noexcept {
40 // Use fully qualified name to avoid ambiguities with MSVC (ARROW-14800)
41 return arrow::internal::launder(reinterpret_cast<const T*>(&data_));
42 }
43
44 void destroy() noexcept {
45 if (!std::is_trivially_destructible<T>::value) {
46 get()->~T();
47 }
48 }
49
50 template <typename... A>
51 void construct(A&&... args) noexcept {
52 new (&data_) T(std::forward<A>(args)...);
53 }
54
55 template <typename V>
56 void assign(V&& v) noexcept {
57 *get() = std::forward<V>(v);
58 }
59
60 void move_construct(AlignedStorage* other) noexcept {
61 new (&data_) T(std::move(*other->get()));
62 }
63
64 void move_assign(AlignedStorage* other) noexcept { *get() = std::move(*other->get()); }
65
66 template <bool CanMemcpy = can_memcpy>
67 static typename std::enable_if<CanMemcpy>::type move_construct_several(
68 AlignedStorage* ARROW_RESTRICT src, AlignedStorage* ARROW_RESTRICT dest, size_t n,
69 size_t memcpy_length) noexcept {
70 memcpy(dest->get(), src->get(), memcpy_length * sizeof(T));
71 }
72
73 template <bool CanMemcpy = can_memcpy>
74 static typename std::enable_if<CanMemcpy>::type
75 move_construct_several_and_destroy_source(AlignedStorage* ARROW_RESTRICT src,
76 AlignedStorage* ARROW_RESTRICT dest, size_t n,
77 size_t memcpy_length) noexcept {
78 memcpy(dest->get(), src->get(), memcpy_length * sizeof(T));
79 }
80
81 template <bool CanMemcpy = can_memcpy>
82 static typename std::enable_if<!CanMemcpy>::type move_construct_several(

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected