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

Side by Side Diff: base/auto_reset.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/atomicops_internals_x86_msvc.h ('k') | base/base64.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef BASE_AUTO_RESET_H_ 5 #ifndef BASE_AUTO_RESET_H_
6 #define BASE_AUTO_RESET_H_ 6 #define BASE_AUTO_RESET_H_
7 #pragma once
8 7
9 #include "base/basictypes.h" 8 #include "base/basictypes.h"
10 9
11 // AutoReset<> is useful for setting a variable to a new value only within a 10 // AutoReset<> is useful for setting a variable to a new value only within a
12 // particular scope. An AutoReset<> object resets a variable to its original 11 // particular scope. An AutoReset<> object resets a variable to its original
13 // value upon destruction, making it an alternative to writing "var = false;" 12 // value upon destruction, making it an alternative to writing "var = false;"
14 // or "var = old_val;" at all of a block's exit points. 13 // or "var = old_val;" at all of a block's exit points.
15 // 14 //
16 // This should be obvious, but note that an AutoReset<> instance should have a 15 // This should be obvious, but note that an AutoReset<> instance should have a
17 // shorter lifetime than its scoped_variable, to prevent invalid memory writes 16 // shorter lifetime than its scoped_variable, to prevent invalid memory writes
(...skipping 11 matching lines...) Expand all
29 ~AutoReset() { *scoped_variable_ = original_value_; } 28 ~AutoReset() { *scoped_variable_ = original_value_; }
30 29
31 private: 30 private:
32 T* scoped_variable_; 31 T* scoped_variable_;
33 T original_value_; 32 T original_value_;
34 33
35 DISALLOW_COPY_AND_ASSIGN(AutoReset); 34 DISALLOW_COPY_AND_ASSIGN(AutoReset);
36 }; 35 };
37 36
38 #endif // BASE_AUTO_RESET_H_ 37 #endif // BASE_AUTO_RESET_H_
OLDNEW
« no previous file with comments | « base/atomicops_internals_x86_msvc.h ('k') | base/base64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698