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

Unified Diff: src/base/flags.h

Issue 527173002: Add support for storage type to base::Flags. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Windows Fix Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/base/flags-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/flags.h
diff --git a/src/base/flags.h b/src/base/flags.h
index 6a2c57f719e1c9127fc309811b85ad0e208d24e3..bf5edbf3f31a17ca7d7faad665972a6d76e5eb88 100644
--- a/src/base/flags.h
+++ b/src/base/flags.h
@@ -11,18 +11,19 @@ namespace v8 {
namespace base {
// The Flags class provides a type-safe way of storing OR-combinations of enum
-// values. The Flags<T> class is a template class, where T is an enum type.
+// values. The Flags<T, S> class is a template class, where T is an enum type,
+// and S is the underlying storage type (usually int).
//
// The traditional C++ approach for storing OR-combinations of enum values is to
// use an int or unsigned int variable. The inconvenience with this approach is
// that there's no type checking at all; any enum value can be OR'd with any
// other enum value and passed on to a function that takes an int or unsigned
// int.
-template <typename T>
+template <typename T, typename S = int>
class Flags V8_FINAL {
public:
typedef T flag_type;
- typedef int mask_type;
+ typedef S mask_type;
Flags() : mask_(0) {}
Flags(flag_type flag) : mask_(flag) {} // NOLINT(runtime/explicit)
@@ -63,8 +64,6 @@ class Flags V8_FINAL {
};
-#define DEFINE_FLAGS(Type, Enum) typedef ::v8::base::Flags<Enum> Type
-
#define DEFINE_OPERATORS_FOR_FLAGS(Type) \
inline ::v8::base::Flags<Type::flag_type> operator&( \
Type::flag_type lhs, \
« no previous file with comments | « no previous file | src/base/flags-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698