Skip to content

Commit 17b4518

Browse files
committed
[io] move AlignedStorage to alignment utils
1 parent 8e401fe commit 17b4518

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

core/foundation/inc/ROOT/RAlignmentUtils.hxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ inline constexpr T AlignUp(T value, T align) noexcept
3535
return (value + align - 1) & ~(align - 1);
3636
}
3737

38+
/// Storage type whose alignment matches \a Align bytes.
39+
/// Used to instantiate std::vector specializations with guaranteed buffer alignment.
40+
template <std::size_t Align>
41+
struct alignas(Align) AlignedStorage {
42+
char data[Align] = {};
43+
};
44+
3845
} // namespace Internal
3946
} // namespace ROOT
4047

io/io/inc/TEmulatedCollectionProxy.h

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,20 @@ class TEmulatedCollectionProxy : public TGenCollectionProxy {
2323
friend class TCollectionProxy;
2424

2525
public:
26-
/// Storage type whose alignment matches \a Align bytes.
27-
/// Used to instantiate std::vector specializations with guaranteed buffer alignment.
28-
template <std::size_t Align>
29-
struct alignas(Align) AlignedStorage {
30-
char data[Align] = {};
31-
};
32-
3326
// Convenience vector aliases for each supported alignment.
34-
using Cont1_t = std::vector<AlignedStorage< 1>>;
35-
using Cont2_t = std::vector<AlignedStorage< 2>>;
36-
using Cont4_t = std::vector<AlignedStorage< 4>>;
37-
using Cont8_t = std::vector<AlignedStorage< 8>>;
38-
using Cont16_t = std::vector<AlignedStorage< 16>>;
39-
using Cont32_t = std::vector<AlignedStorage< 32>>;
40-
using Cont64_t = std::vector<AlignedStorage< 64>>;
41-
using Cont128_t = std::vector<AlignedStorage< 128>>;
42-
using Cont256_t = std::vector<AlignedStorage< 256>>;
43-
using Cont512_t = std::vector<AlignedStorage< 512>>;
44-
using Cont1024_t = std::vector<AlignedStorage<1024>>;
45-
using Cont2048_t = std::vector<AlignedStorage<2048>>;
46-
using Cont4096_t = std::vector<AlignedStorage<4096>>;
27+
using Cont1_t = std::vector<ROOT::Internal::AlignedStorage< 1>>;
28+
using Cont2_t = std::vector<ROOT::Internal::AlignedStorage< 2>>;
29+
using Cont4_t = std::vector<ROOT::Internal::AlignedStorage< 4>>;
30+
using Cont8_t = std::vector<ROOT::Internal::AlignedStorage< 8>>;
31+
using Cont16_t = std::vector<ROOT::Internal::AlignedStorage< 16>>;
32+
using Cont32_t = std::vector<ROOT::Internal::AlignedStorage< 32>>;
33+
using Cont64_t = std::vector<ROOT::Internal::AlignedStorage< 64>>;
34+
using Cont128_t = std::vector<ROOT::Internal::AlignedStorage< 128>>;
35+
using Cont256_t = std::vector<ROOT::Internal::AlignedStorage< 256>>;
36+
using Cont512_t = std::vector<ROOT::Internal::AlignedStorage< 512>>;
37+
using Cont1024_t = std::vector<ROOT::Internal::AlignedStorage<1024>>;
38+
using Cont2048_t = std::vector<ROOT::Internal::AlignedStorage<2048>>;
39+
using Cont4096_t = std::vector<ROOT::Internal::AlignedStorage<4096>>;
4740

4841
// Canonical container type (used for sizeof/typeid; actual alignment is
4942
// selected at runtime via the alignment switch in each method).

0 commit comments

Comments
 (0)