1/***************************************************************************
2 * Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and *
3 * Martin Renou *
4 * Copyright (c) QuantStack *
5 * Copyright (c) Serge Guelton *
6 * *
7 * Distributed under the terms of the BSD 3-Clause License. *
8 * *
9 * The full license is in the file LICENSE, distributed with this software. *
10 ****************************************************************************/
11
12#ifndef XSIMD_ALIGNMENT_HPP
13#define XSIMD_ALIGNMENT_HPP
14
15#include "../types/xsimd_utils.hpp"
16#include "xsimd_aligned_allocator.hpp"
17
18namespace xsimd
19{
20 /**
21 * @struct aligned_mode
22 * @brief tag for load and store of aligned memory.
23 */
24 struct aligned_mode
25 {
26 };
27
28 /**
29 * @struct unaligned_mode
30 * @brief tag for load and store of unaligned memory.
31 */
32 struct unaligned_mode
33 {
34 };
35
36 /***********************
37 * Allocator alignment *
38 ***********************/
39
40 template <class A>
41 struct allocator_alignment
42 {
43 using type = unaligned_mode;
44 };
45
46 template <class T>
47 struct allocator_alignment<aligned_allocator<T>>
48 {
49 using type = aligned_mode;
50 };
51
52 template <class A>
53 using allocator_alignment_t = typename allocator_alignment<A>::type;
54
55 /***********************
56 * container alignment *
57 ***********************/
58
59 template <class C, class = void>
60 struct container_alignment
61 {
62 using type = unaligned_mode;
63 };
64
65 template <class C>
66 struct container_alignment<C, detail::void_t<typename C::allocator_type>>
67 {
68 using type = allocator_alignment_t<typename C::allocator_type>;
69 };
70
71 template <class C>
72 using container_alignment_t = typename container_alignment<C>::type;
73
74}
75
76#endif
77