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

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

Issue 2038273002: Remove base/move.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: is_constructible Created 4 years, 6 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/filter_chain.h ('k') | mojo/public/cpp/bindings/map.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 #include <type_traits> 8 #include <type_traits>
9 9
10 namespace mojo { 10 namespace mojo {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 struct NoType { 46 struct NoType {
47 YesType dummy[2]; 47 YesType dummy[2];
48 }; 48 };
49 49
50 // A helper template to determine if given type is non-const move-only-type, 50 // A helper template to determine if given type is non-const move-only-type,
51 // i.e. if a value of the given type should be passed via std::move() in a 51 // i.e. if a value of the given type should be passed via std::move() in a
52 // destructive way. 52 // destructive way.
53 template <typename T> 53 template <typename T>
54 struct IsMoveOnlyType { 54 struct IsMoveOnlyType {
55 template <typename U> 55 static const bool value = std::is_constructible<T, T&&>::value &&
56 static YesType Test(const typename U::MoveOnlyTypeForCPP03*); 56 !std::is_constructible<T, const T&>::value;
57
58 template <typename U>
59 static NoType Test(...);
60
61 static const bool value =
62 sizeof(Test<T>(0)) == sizeof(YesType) && !IsConst<T>::value;
63 }; 57 };
64 58
65 // This goop is a trick used to implement a template that can be used to 59 // This goop is a trick used to implement a template that can be used to
66 // determine if a given class is the base class of another given class. 60 // determine if a given class is the base class of another given class.
67 template <typename, typename> 61 template <typename, typename>
68 struct IsSame { 62 struct IsSame {
69 static bool const value = false; 63 static bool const value = false;
70 }; 64 };
71 template <typename A> 65 template <typename A>
72 struct IsSame<A, A> { 66 struct IsSame<A, A> {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 template <typename T, 159 template <typename T,
166 typename std::enable_if<!HasEqualsMethod<T>::value>::type* = nullptr> 160 typename std::enable_if<!HasEqualsMethod<T>::value>::type* = nullptr>
167 bool Equals(const T& a, const T& b) { 161 bool Equals(const T& a, const T& b) {
168 return a == b; 162 return a == b;
169 } 163 }
170 164
171 } // namespace internal 165 } // namespace internal
172 } // namespace mojo 166 } // namespace mojo
173 167
174 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_TEMPLATE_UTIL_H_ 168 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_TEMPLATE_UTIL_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/filter_chain.h ('k') | mojo/public/cpp/bindings/map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698