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

Unified Diff: third_party/mojo/src/mojo/public/cpp/bindings/lib/callback_internal.h

Issue 917433003: Update mojo sdk to rev 1027d24a1f68c6d10b7539b32114f1272b2cc9f1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add //build/module_args/mojo.gni. Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/mojo/src/mojo/public/cpp/bindings/lib/callback_internal.h
diff --git a/third_party/mojo/src/mojo/public/cpp/bindings/lib/callback_internal.h b/third_party/mojo/src/mojo/public/cpp/bindings/lib/callback_internal.h
index f76ebef59e6c67ba12b4f13e67534be49cc3cdb7..9df5b40a73555e7f72aa8ac046a62aefd1701058 100644
--- a/third_party/mojo/src/mojo/public/cpp/bindings/lib/callback_internal.h
+++ b/third_party/mojo/src/mojo/public/cpp/bindings/lib/callback_internal.h
@@ -5,6 +5,8 @@
#ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_CALLBACK_INTERNAL_H_
#define MOJO_PUBLIC_CPP_BINDINGS_LIB_CALLBACK_INTERNAL_H_
+#include "mojo/public/cpp/bindings/lib/template_util.h"
+
namespace mojo {
class String;
@@ -20,6 +22,31 @@ struct Callback_ParamTraits<String> {
typedef const String& ForwardType;
};
+template <typename T, typename... Args>
+struct HasCompatibleCallOperator {
+ // This template's second parameter is the signature of the operator()
+ // overload we want to try to detect:
+ // void operator()(Args...) const;
+ template <typename U,
+ void (U::*)(
+ typename internal::Callback_ParamTraits<Args>::ForwardType...)
+ const>
+ struct TestType {};
+
+ // This matches type U if it has a call operator with the
+ // expected signature.
+ template <typename U>
+ static YesType Test(TestType<U, &U::operator()>*);
+
+ // This matches anything else.
+ template <typename U>
+ static NoType Test(...);
+
+ // HasCompatibleCallOperator<T, Args...>::value will be true if T has a
+ // compatible call operator.
+ enum { value = (sizeof(Test<T>(nullptr)) == sizeof(YesType)) };
+};
+
} // namespace internal
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698