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

Side by Side Diff: mojo/public/cpp/bindings/lib/template_util.h

Issue 622593002: mojo: Allow circular dependencies between structs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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
« no previous file with comments | « mojo/public/cpp/bindings/lib/bindings_internal.h ('k') | mojo/public/cpp/bindings/struct_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 MOJO_PUBLIC_CPP_BINDINGS_LIB_TEMPLATE_UTIL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_TEMPLATE_UTIL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_TEMPLATE_UTIL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_TEMPLATE_UTIL_H_
7 7
8 namespace mojo { 8 namespace mojo {
9 namespace internal { 9 namespace internal {
10 10
11 template <class T, T v> 11 template <class T, T v>
12 struct IntegralConstant { 12 struct IntegralConstant {
13 static const T value = v; 13 static const T value = v;
14 }; 14 };
15 15
16 template <class T, T v> 16 template <class T, T v>
17 const T IntegralConstant<T, v>::value; 17 const T IntegralConstant<T, v>::value;
18 18
19 typedef IntegralConstant<bool, true> TrueType; 19 typedef IntegralConstant<bool, true> TrueType;
20 typedef IntegralConstant<bool, false> FalseType; 20 typedef IntegralConstant<bool, false> FalseType;
21 21
22 template <class T> 22 template <class T>
23 struct IsConst : FalseType {}; 23 struct IsConst : FalseType {};
24 template <class T> 24 template <class T>
25 struct IsConst<const T> : TrueType {}; 25 struct IsConst<const T> : TrueType {};
26 26
27 template <class T>
28 struct IsPointer : FalseType {};
29 template <class T>
30 struct IsPointer<T*> : TrueType {};
31
27 template <bool B, typename T = void> 32 template <bool B, typename T = void>
28 struct EnableIf {}; 33 struct EnableIf {};
29 34
30 template <typename T> 35 template <typename T>
31 struct EnableIf<true, T> { 36 struct EnableIf<true, T> {
32 typedef T type; 37 typedef T type;
33 }; 38 };
34 39
35 // Types YesType and NoType are guaranteed such that sizeof(YesType) < 40 // Types YesType and NoType are guaranteed such that sizeof(YesType) <
36 // sizeof(NoType). 41 // sizeof(NoType).
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 90
86 static Derived* CreateDerived(); 91 static Derived* CreateDerived();
87 static char(&Check(Base*))[1]; 92 static char(&Check(Base*))[1];
88 static char(&Check(...))[2]; 93 static char(&Check(...))[2];
89 94
90 public: 95 public:
91 static bool const value = sizeof Check(CreateDerived()) == 1 && 96 static bool const value = sizeof Check(CreateDerived()) == 1 &&
92 !IsSame<Base const, void const>::value; 97 !IsSame<Base const, void const>::value;
93 }; 98 };
94 99
100 template <class T>
101 struct RemovePointer {};
102 template <class T>
103 struct RemovePointer<T*> {
104 typedef T type;
105 };
106
95 } // namespace internal 107 } // namespace internal
96 } // namespace mojo 108 } // namespace mojo
97 109
98 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_TEMPLATE_UTIL_H_ 110 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_TEMPLATE_UTIL_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/bindings_internal.h ('k') | mojo/public/cpp/bindings/struct_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698