ATLAS Offline Software
Loading...
Searching...
No Matches
AlignedDynArray.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10#ifndef GSFUtils_AlignedDynArray_H
11#define GSFUtils_AlignedDynArray_H
12#include <cstdlib>
13#include <memory>
14#include <type_traits>
15namespace GSFUtils {
16
28template<typename T, size_t ALIGNMENT>
30{
31
32 // These come from the posix_memalign
33 // which is the typical underlying implementation
34 static_assert(ALIGNMENT != 0, "Zero alignment 0");
35 static_assert(
36 (ALIGNMENT & (ALIGNMENT - 1)) == 0,
37 "Alignment not a power of 2");
38 static_assert(
39 (ALIGNMENT % sizeof(void*)) == 0,
40 "Alignment not an integral multiple of sizeof(void*)");
41 //Also we assert is POD
42 static_assert(
43 std::is_standard_layout_v<T>,
44 "Type T is not standard layout");
46 // Standard typedefs
47 typedef T value_type;
48 typedef T* pointer;
49 typedef const T* const_pointer;
53 typedef const value_type* const_iterator;
54 typedef std::size_t size_type;
55 typedef std::ptrdiff_t difference_type;
57
59 AlignedDynArray() = delete;
60
63
66
68 explicit AlignedDynArray(const size_type n);
69
71 explicit AlignedDynArray(const size_type n, const T& value);
72
75
77 AlignedDynArray& operator=(AlignedDynArray&&) noexcept;
78
81
83 pointer buffer() noexcept;
84
87
89 reference operator[](size_type pos) noexcept;
90
92 const_reference operator[](size_type pos) const noexcept;
93
95 iterator begin() noexcept;
96
99
101 iterator end() noexcept;
102
105
107 size_type size() const noexcept;
108
110 bool empty() const noexcept;
111
112private:
114 void cleanup();
115
117 pointer m_buffer = nullptr;
118
121};
122
123} // namespace GSFUtils
124
125// impl .icc
126#include "TrkGaussianSumFilterUtils/AlignedDynArray.icc"
127
128#endif
Dynamic array fullfilling alignment requirements.
AlignedDynArray(AlignedDynArray &&) noexcept
Move copy constructor.
const value_type * const_iterator
AlignedDynArray & operator=(AlignedDynArray const &)=delete
Deleted default assignment operator.
AlignedDynArray(const size_type n, const T &value)
Constructor initializing elements to value.
const value_type & const_reference
AlignedDynArray(const size_type n)
Constructor with default initializing elements.
AlignedDynArray()=delete
Deleted default constructor.
AlignedDynArray(AlignedDynArray const &)=delete
Deleted default copy constructor.
#define private