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

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

Issue 2047633002: Revert of Remove base/move.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 #include "base/template_util.h"
11
12 namespace mojo { 10 namespace mojo {
13 namespace internal { 11 namespace internal {
14 12
15 template <class T, T v> 13 template <class T, T v>
16 struct IntegralConstant { 14 struct IntegralConstant {
17 static const T value = v; 15 static const T value = v;
18 }; 16 };
19 17
20 template <class T, T v> 18 template <class T, T v>
21 const T IntegralConstant<T, v>::value; 19 const T IntegralConstant<T, v>::value;
(...skipping 25 matching lines...) Expand all
47 45
48 struct NoType { 46 struct NoType {
49 YesType dummy[2]; 47 YesType dummy[2];
50 }; 48 };
51 49
52 // 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,
53 // 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
54 // destructive way. 52 // destructive way.
55 template <typename T> 53 template <typename T>
56 struct IsMoveOnlyType { 54 struct IsMoveOnlyType {
55 template <typename U>
56 static YesType Test(const typename U::MoveOnlyTypeForCPP03*);
57
58 template <typename U>
59 static NoType Test(...);
60
57 static const bool value = 61 static const bool value =
58 base::is_move_assignable<T>::value && !base::is_copy_assignable<T>::value; 62 sizeof(Test<T>(0)) == sizeof(YesType) && !IsConst<T>::value;
59 }; 63 };
60 64
61 // This goop is a trick used to implement a template that can be used to 65 // This goop is a trick used to implement a template that can be used to
62 // determine if a given class is the base class of another given class. 66 // determine if a given class is the base class of another given class.
63 template <typename, typename> 67 template <typename, typename>
64 struct IsSame { 68 struct IsSame {
65 static bool const value = false; 69 static bool const value = false;
66 }; 70 };
67 template <typename A> 71 template <typename A>
68 struct IsSame<A, A> { 72 struct IsSame<A, A> {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 template <typename T, 165 template <typename T,
162 typename std::enable_if<!HasEqualsMethod<T>::value>::type* = nullptr> 166 typename std::enable_if<!HasEqualsMethod<T>::value>::type* = nullptr>
163 bool Equals(const T& a, const T& b) { 167 bool Equals(const T& a, const T& b) {
164 return a == b; 168 return a == b;
165 } 169 }
166 170
167 } // namespace internal 171 } // namespace internal
168 } // namespace mojo 172 } // namespace mojo
169 173
170 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_TEMPLATE_UTIL_H_ 174 #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