1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34

base / functional / callback_tags.h [blame]

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This defines helpful tags for dealing with Callbacks. Those tags can be used
// to construct special callbacks. This lives in its own file to avoid circular
// dependencies.

#ifndef BASE_FUNCTIONAL_CALLBACK_TAGS_H_
#define BASE_FUNCTIONAL_CALLBACK_TAGS_H_

namespace base::internal {

struct NullCallbackTag {
  template <typename Signature>
  struct WithSignature {};
};

struct DoNothingCallbackTag {
  template <typename Signature>
  struct WithSignature {};

  template <typename... BoundArgs>
  struct WithBoundArguments {
    std::tuple<BoundArgs...> bound_args;

    constexpr explicit WithBoundArguments(BoundArgs... args)
        : bound_args(std::forward<BoundArgs>(args)...) {}
  };
};

}  // namespace base::internal

#endif  // BASE_FUNCTIONAL_CALLBACK_TAGS_H_