File indexing completed on 2025-08-28 09:11:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef XSIMD_ALIGNMENT_HPP
0013 #define XSIMD_ALIGNMENT_HPP
0014
0015 #include "../types/xsimd_utils.hpp"
0016 #include "xsimd_aligned_allocator.hpp"
0017
0018 namespace xsimd
0019 {
0020
0021
0022
0023
0024 struct aligned_mode
0025 {
0026 };
0027
0028
0029
0030
0031
0032 struct unaligned_mode
0033 {
0034 };
0035
0036
0037
0038
0039
0040 template <class A>
0041 struct allocator_alignment
0042 {
0043 using type = unaligned_mode;
0044 };
0045
0046 template <class T, size_t N>
0047 struct allocator_alignment<aligned_allocator<T, N>>
0048 {
0049 using type = aligned_mode;
0050 };
0051
0052 template <class A>
0053 using allocator_alignment_t = typename allocator_alignment<A>::type;
0054
0055
0056
0057
0058
0059 template <class C, class = void>
0060 struct container_alignment
0061 {
0062 using type = unaligned_mode;
0063 };
0064
0065 template <class C>
0066 struct container_alignment<C, detail::void_t<typename C::allocator_type>>
0067 {
0068 using type = allocator_alignment_t<typename C::allocator_type>;
0069 };
0070
0071 template <class C>
0072 using container_alignment_t = typename container_alignment<C>::type;
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 template <class Arch = default_arch>
0084 XSIMD_INLINE bool is_aligned(void const* ptr)
0085 {
0086 return (reinterpret_cast<uintptr_t>(ptr) % static_cast<uintptr_t>(Arch::alignment())) == 0;
0087 }
0088
0089 }
0090
0091 #endif