Index: mojo/public/cpp/bindings/lib/bindings_internal.h |
diff --git a/mojo/public/cpp/bindings/lib/bindings_internal.h b/mojo/public/cpp/bindings/lib/bindings_internal.h |
index 4b847e71e3c8f7c98a70db1f2fe9f9b57332bf82..56ab6725141d11e78f7852c4183ac03d478e3d64 100644 |
--- a/mojo/public/cpp/bindings/lib/bindings_internal.h |
+++ b/mojo/public/cpp/bindings/lib/bindings_internal.h |
@@ -158,6 +158,43 @@ template <typename S> struct TypeTraits<InterfaceHandle<S> > { |
template <typename T> class ObjectTraits {}; |
+template<class T, T v> |
+struct integral_constant { |
+ static const T value = v; |
+ typedef T value_type; |
+ typedef integral_constant<T, v> type; |
+}; |
+ |
+template <class T, T v> const T integral_constant<T, v>::value; |
+ |
+typedef integral_constant<bool, true> true_type; |
+typedef integral_constant<bool, false> false_type; |
+ |
+template <class T> struct is_const : false_type {}; |
+template <class T> struct is_const<const T> : true_type {}; |
+ |
+// Types YesType and NoType are guaranteed such that sizeof(YesType) < |
+// sizeof(NoType). |
+typedef char YesType; |
+ |
+struct NoType { |
+ YesType dummy[2]; |
+}; |
+ |
+// A helper template to determine if given type is non-const move-only-type, |
+// i.e. if a value of the given type should be passed via .Pass() in a |
+// destructive way. |
+template <typename T> struct IsMoveOnlyType { |
+ template <typename U> |
+ static YesType Test(const typename U::MoveOnlyTypeForCPP03*); |
+ |
+ template <typename U> |
+ static NoType Test(...); |
+ |
+ static const bool value = sizeof(Test<T>(0)) == sizeof(YesType) && |
+ !is_const<T>::value; |
+}; |
+ |
} // namespace internal |
} // namespace mojo |