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

Side by Side Diff: src/core/SkEnumOperators.h

Issue 2246903002: SkPDF: SkPDFFont class changes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-08-15 (Monday) 17:11:22 EDT Created 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7 #ifndef SkEnumOperators_DEFINED
8 #define SkEnumOperators_DEFINED
bungeman-skia 2016/08/15 21:41:36 I don't think these are generally desirable enum o
hal.canary 2016/08/16 01:27:38 Done.
9
10 #include "SkTLogic.h"
11
12 namespace skstd {
13 template <typename T> struct is_bitmask_enum : std::false_type {};
14 }
15
16 template <typename E>
17 SK_WHEN(skstd::is_bitmask_enum<E>::value, E) operator|(E l, E r) {
bungeman-skia 2016/08/15 21:41:36 nit: I personally prefer lines 16 and 17 here on o
hal.canary 2016/08/16 01:27:38 Done.
18 using U = skstd::underlying_type_t<E>;
19 return static_cast<E>(static_cast<U>(l) | static_cast<U>(r));
20 }
21
22 template <typename E>
23 SK_WHEN(skstd::is_bitmask_enum<E>::value, E&) operator|=(E& l, E r) {
24 return l = l | r;
25 }
26
27 template <typename E>
28 SK_WHEN(skstd::is_bitmask_enum<E>::value, E) operator&(E l, E r) {
29 using U = skstd::underlying_type_t<E>;
30 return static_cast<E>(static_cast<U>(l) & static_cast<U>(r));
31 }
32
33 template <typename E>
34 SK_WHEN(skstd::is_bitmask_enum<E>::value, E&) operator&=(E& l, E r) {
35 return l = l & r;
36 }
37
38 #endif // SkEnumOperators_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698