blob: 0622f9678cb57b84d4ff57ff77fde384746dcf7d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_SCOPED_BOOL_H_
#define BASE_SCOPED_BOOL_H_
// ScopedBool is useful for setting a flag only during a particular scope. If
// you have code that has to add "var = false;" at all the exit points of a
// function, for example, you would benefit from using this instead.
class ScopedBool {
public:
explicit ScopedBool(bool* scoped_bool) : scoped_bool_(scoped_bool) {
*scoped_bool_ = true;
}
~ScopedBool() { *scoped_bool_ = false; }
private:
bool* scoped_bool_;
DISALLOW_COPY_AND_ASSIGN(ScopedBool);
};
#endif // BASE_SCOPED_BOOL_H_
|