diff options
author | rockot <rockot@chromium.org> | 2015-11-12 17:33:59 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-13 01:34:47 +0000 |
commit | 85dce086001825a2faa4e75755a669f5e08a1cad (patch) | |
tree | 722de1d974f799b3d1ee1ca4c81bb8b0fa75a95d /mojo/public/cpp/bindings/lib/callback_internal.h | |
parent | 415b73b1a400a994a86e6f29709aa0271e895dd5 (diff) | |
download | chromium_src-85dce086001825a2faa4e75755a669f5e08a1cad.zip chromium_src-85dce086001825a2faa4e75755a669f5e08a1cad.tar.gz chromium_src-85dce086001825a2faa4e75755a669f5e08a1cad.tar.bz2 |
Move third_party/mojo/src/mojo/public to mojo/public
BUG=None
NOPRESUBMIT=true
Review URL: https://codereview.chromium.org/1410053006
Cr-Commit-Position: refs/heads/master@{#359461}
Diffstat (limited to 'mojo/public/cpp/bindings/lib/callback_internal.h')
-rw-r--r-- | mojo/public/cpp/bindings/lib/callback_internal.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/mojo/public/cpp/bindings/lib/callback_internal.h b/mojo/public/cpp/bindings/lib/callback_internal.h new file mode 100644 index 0000000..9df5b40a7 --- /dev/null +++ b/mojo/public/cpp/bindings/lib/callback_internal.h @@ -0,0 +1,53 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#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; + +namespace internal { + +template <typename T> +struct Callback_ParamTraits { + typedef T ForwardType; +}; + +template <> +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 + +#endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CALLBACK_INTERNAL_H_ |