// src\base\callback.htemplate<typename R,typename... Args>classRepeatingCallback<R(Args...)>:public internal::CallbackBaseCopyable {
public:using RunType =R(Args...);using PolymorphicInvoke = R (*)(internal::BindStateBase*,
internal::PassingTraitsType<Args>...);constexprRepeatingCallback()=default;explicitRepeatingCallback(internal::BindStateBase* bind_state): internal::CallbackBaseCopyable(bind_state){
}// Copyable and movable.RepeatingCallback(const RepeatingCallback&)=default;
RepeatingCallback&operator=(const RepeatingCallback&)=default;RepeatingCallback(RepeatingCallback&&)noexcept=default;
RepeatingCallback&operator=(RepeatingCallback&&)noexcept=default;boolEquals(const RepeatingCallback& other)const{
returnEqualsInternal(other);}
R Run(Args... args)const&{
PolymorphicInvoke f =reinterpret_cast<PolymorphicInvoke>(this->polymorphic_invoke());returnf(this->bind_state_.get(), std::forward<Args>(args)...);}
R Run(Args... args)&&{
// Move the callback instance into a local variable before the invocation,// that ensures the internal state is cleared after the invocation.// It's not safe to touch |this| after the invocation, since running the// bound function may destroy |this|.
RepeatingCallback cb = std::move(*this);
PolymorphicInvoke f =reinterpret_cast<PolymorphicInvoke>(cb.polymorphic_invoke());returnf(cb.bind_state_.get(), std::forward<Args>(args)...);}};