Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: base/memory/aligned_memory.h

Issue 10735044: Remove #pragma once. Just from base/ for now. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/md5.h ('k') | base/memory/linked_ptr.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // AlignedMemory is a POD type that gives you a portable way to specify static 5 // AlignedMemory is a POD type that gives you a portable way to specify static
6 // or local stack data of a given alignment and size. For example, if you need 6 // or local stack data of a given alignment and size. For example, if you need
7 // static storage for a class, but you want manual control over when the object 7 // static storage for a class, but you want manual control over when the object
8 // is constructed and destructed (you don't want static initialization and 8 // is constructed and destructed (you don't want static initialization and
9 // destruction), use AlignedMemory: 9 // destruction), use AlignedMemory:
10 // 10 //
11 // static AlignedMemory<sizeof(MyClass), ALIGNOF(MyClass)> my_class; 11 // static AlignedMemory<sizeof(MyClass), ALIGNOF(MyClass)> my_class;
12 // 12 //
13 // // ... at runtime: 13 // // ... at runtime:
14 // new(my_class.void_data()) MyClass(); 14 // new(my_class.void_data()) MyClass();
15 // 15 //
16 // // ... use it: 16 // // ... use it:
17 // MyClass* mc = my_class.data_as<MyClass>(); 17 // MyClass* mc = my_class.data_as<MyClass>();
18 // 18 //
19 // // ... later, to destruct my_class: 19 // // ... later, to destruct my_class:
20 // my_class.data_as<MyClass>()->MyClass::~MyClass(); 20 // my_class.data_as<MyClass>()->MyClass::~MyClass();
21 21
22 #ifndef BASE_MEMORY_ALIGNED_MEMORY_H_ 22 #ifndef BASE_MEMORY_ALIGNED_MEMORY_H_
23 #define BASE_MEMORY_ALIGNED_MEMORY_H_ 23 #define BASE_MEMORY_ALIGNED_MEMORY_H_
24 #pragma once
25 24
26 #include "base/basictypes.h" 25 #include "base/basictypes.h"
27 #include "base/compiler_specific.h" 26 #include "base/compiler_specific.h"
28 #include "base/logging.h" 27 #include "base/logging.h"
29 28
30 namespace base { 29 namespace base {
31 30
32 // AlignedMemory is specialized for all supported alignments. 31 // AlignedMemory is specialized for all supported alignments.
33 // Make sure we get a compiler error if someone uses an unsupported alignment. 32 // Make sure we get a compiler error if someone uses an unsupported alignment.
34 template <size_t Size, size_t ByteAlignment> 33 template <size_t Size, size_t ByteAlignment>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 BASE_DECL_ALIGNED_MEMORY(128); 67 BASE_DECL_ALIGNED_MEMORY(128);
69 BASE_DECL_ALIGNED_MEMORY(256); 68 BASE_DECL_ALIGNED_MEMORY(256);
70 BASE_DECL_ALIGNED_MEMORY(512); 69 BASE_DECL_ALIGNED_MEMORY(512);
71 BASE_DECL_ALIGNED_MEMORY(1024); 70 BASE_DECL_ALIGNED_MEMORY(1024);
72 BASE_DECL_ALIGNED_MEMORY(2048); 71 BASE_DECL_ALIGNED_MEMORY(2048);
73 BASE_DECL_ALIGNED_MEMORY(4096); 72 BASE_DECL_ALIGNED_MEMORY(4096);
74 73
75 } // base 74 } // base
76 75
77 #endif // BASE_MEMORY_ALIGNED_MEMORY_H_ 76 #endif // BASE_MEMORY_ALIGNED_MEMORY_H_
OLDNEW
« no previous file with comments | « base/md5.h ('k') | base/memory/linked_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698