// 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 struct Callback_ParamTraits { typedef T ForwardType; }; template <> struct Callback_ParamTraits { typedef const String& ForwardType; }; template 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 ::ForwardType...) const> struct TestType {}; // This matches type U if it has a call operator with the // expected signature. template static YesType Test(TestType*); // This matches anything else. template static NoType Test(...); // HasCompatibleCallOperator::value will be true if T has a // compatible call operator. enum { value = (sizeof(Test(nullptr)) == sizeof(YesType)) }; }; } // namespace internal } // namespace mojo #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CALLBACK_INTERNAL_H_