BRE12
aligned_space.h
1 /*
2  Copyright 2005-2016 Intel Corporation. All Rights Reserved.
3 
4  This file is part of Threading Building Blocks. Threading Building Blocks is free software;
5  you can redistribute it and/or modify it under the terms of the GNU General Public License
6  version 2 as published by the Free Software Foundation. Threading Building Blocks is
7  distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
8  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9  See the GNU General Public License for more details. You should have received a copy of
10  the GNU General Public License along with Threading Building Blocks; if not, write to the
11  Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
12 
13  As a special exception, you may use this file as part of a free software library without
14  restriction. Specifically, if other files instantiate templates or use macros or inline
15  functions from this file, or you compile this file and link it with other files to produce
16  an executable, this file does not by itself cause the resulting executable to be covered
17  by the GNU General Public License. This exception does not however invalidate any other
18  reasons why the executable file might be covered by the GNU General Public License.
19 */
20 
21 #ifndef __TBB_aligned_space_H
22 #define __TBB_aligned_space_H
23 
24 #include "tbb_stddef.h"
25 #include "tbb_machine.h"
26 
27 namespace tbb {
28 
30 
32 template<typename T,size_t N=1>
34 private:
35  typedef __TBB_TypeWithAlignmentAtLeastAsStrict(T) element_type;
36  element_type array[(sizeof(T)*N+sizeof(element_type)-1)/sizeof(element_type)];
37 public:
39  T* begin() {return internal::punned_cast<T*>(this);}
40 
42  T* end() {return begin()+N;}
43 };
44 
45 } // namespace tbb
46 
47 #endif /* __TBB_aligned_space_H */
Block of space aligned sufficiently to construct an array T with N elements.
Definition: aligned_space.h:33
T * end()
Pointer to one past last element in array.
Definition: aligned_space.h:42
T * begin()
Pointer to beginning of array.
Definition: aligned_space.h:39
The namespace tbb contains all components of the library.
Definition: parallel_for.h:44