123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #ifndef BASE_BIND_HELPERS_H_
- #define BASE_BIND_HELPERS_H_
- #include <stddef.h>
- #include <type_traits>
- #include <utility>
- #include "base/bind.h"
- #include "base/callback.h"
- #include "base/memory/weak_ptr.h"
- #include "build/build_config.h"
- namespace base {
- class BASE_EXPORT NullCallback {
- public:
- template <typename R, typename... Args>
- operator RepeatingCallback<R(Args...)>() const {
- return RepeatingCallback<R(Args...)>();
- }
- template <typename R, typename... Args>
- operator OnceCallback<R(Args...)>() const {
- return OnceCallback<R(Args...)>();
- }
- };
- class BASE_EXPORT DoNothing {
- public:
- template <typename... Args>
- operator RepeatingCallback<void(Args...)>() const {
- return Repeatedly<Args...>();
- }
- template <typename... Args>
- operator OnceCallback<void(Args...)>() const {
- return Once<Args...>();
- }
-
-
- template <typename... Args>
- static RepeatingCallback<void(Args...)> Repeatedly() {
- return BindRepeating([](Args... args) {});
- }
- template <typename... Args>
- static OnceCallback<void(Args...)> Once() {
- return BindOnce([](Args... args) {});
- }
- };
- template <typename T>
- void DeletePointer(T* obj) {
- delete obj;
- }
- }
- #endif
|