ROOT  6.06/09
Reference Guide
vectormemoryhelper.h
Go to the documentation of this file.
1 /* This file is part of the Vc library.
2 
3  Copyright (C) 2009 Matthias Kretz <kretz@kde.org>
4 
5  Vc is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as
7  published by the Free Software Foundation, either version 3 of
8  the License, or (at your option) any later version.
9 
10  Vc is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with Vc. If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 
20 #ifndef VECTORMEMORYHELPER_H
21 #define VECTORMEMORYHELPER_H
22 
23 #include <Vc/vector.h>
24 
25 template<typename Vec>
27 {
28  char *const mem;
29  char *const aligned;
30  public:
31  VectorMemoryHelper(int count)
32  : mem(new char[count * sizeof(Vec) + Vc::VectorAlignment]),
33  aligned(mem + (Vc::VectorAlignment - (reinterpret_cast<unsigned long>( mem ) & ( Vc::VectorAlignment - 1 ))))
34  {
35  }
36  ~VectorMemoryHelper() { delete[] mem; }
37 
38  operator typename Vec::EntryType *() { return reinterpret_cast<typename Vec::EntryType *>(aligned); }
39 };
40 
41 #endif // VECTORMEMORYHELPER_H
VectorMemoryHelper(int count)
Definition: casts.h:28