// Copyright (c) 2012 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. // This defines helpful methods for dealing with Callbacks. Because Callbacks // are implemented using templates, with a class per callback signature, adding // methods to Callback<> itself is unattractive (lots of extra code gets // generated). Instead, consider adding methods here. #ifndef BASE_CALLBACK_HELPERS_H_ #define BASE_CALLBACK_HELPERS_H_ #include #include #include #include #include "base/atomicops.h" #include "base/bind.h" #include "base/callback.h" namespace base { namespace internal { template struct IsBaseCallbackImpl : std::false_type {}; template struct IsBaseCallbackImpl> : std::true_type {}; template struct IsBaseCallbackImpl> : std::true_type {}; template struct IsOnceCallbackImpl : std::false_type {}; template struct IsOnceCallbackImpl> : std::true_type {}; } // namespace internal // IsBaseCallback::value is true when T is any of the Closure or Callback // family of types. template using IsBaseCallback = internal::IsBaseCallbackImpl>; // IsOnceCallback::value is true when T is a OnceClosure or OnceCallback // type. template using IsOnceCallback = internal::IsOnceCallbackImpl>; // SFINAE friendly enabler allowing to overload methods for both Repeating and // OnceCallbacks. // // Usage: // template