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

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

Issue 923033003: Implement unions as members of structs. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 8 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
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
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 static Derived* CreateDerived(); 93 static Derived* CreateDerived();
94 static char(&Check(Base*))[1]; 94 static char(&Check(Base*))[1];
95 static char(&Check(...))[2]; 95 static char(&Check(...))[2];
96 96
97 public: 97 public:
98 static bool const value = sizeof Check(CreateDerived()) == 1 && 98 static bool const value = sizeof Check(CreateDerived()) == 1 &&
99 !IsSame<Base const, void const>::value; 99 !IsSame<Base const, void const>::value;
100 }; 100 };
101 101
102 template <class T> 102 template <class T>
103 struct RemovePointer {}; 103 struct RemovePointer {
104 typedef T type;
105 };
104 template <class T> 106 template <class T>
105 struct RemovePointer<T*> { 107 struct RemovePointer<T*> {
106 typedef T type; 108 typedef T type;
107 }; 109 };
108 110
109 template <template <typename...> class Template, typename T> 111 template <template <typename...> class Template, typename T>
110 struct IsSpecializationOf : FalseType {}; 112 struct IsSpecializationOf : FalseType {};
111 113
112 template <template <typename...> class Template, typename... Args> 114 template <template <typename...> class Template, typename... Args>
113 struct IsSpecializationOf<Template, Template<Args...>> : TrueType {}; 115 struct IsSpecializationOf<Template, Template<Args...>> : TrueType {};
114 116
115 template <bool B, typename T, typename F> 117 template <bool B, typename T, typename F>
116 struct Conditional { 118 struct Conditional {
117 typedef T type; 119 typedef T type;
118 }; 120 };
119 121
120 template <typename T, typename F> 122 template <typename T, typename F>
121 struct Conditional<false, T, F> { 123 struct Conditional<false, T, F> {
122 typedef F type; 124 typedef F type;
123 }; 125 };
124 126
125 } // namespace internal 127 } // namespace internal
126 } // namespace mojo 128 } // namespace mojo
127 129
128 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_TEMPLATE_UTIL_H_ 130 #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/tests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698