BDE 4.14.0 Production release
|
Provide a functor class that does nothing.
This component provides a class, bdlf::NoOp
, that is a functor whose function-call operator accepts any number of arguments, does nothing (leaving all arguments unmodified), and returns void
. On platforms where inline
constexpr
variables are supported, this component also provides bdlf::noOp
, which is a constexpr
variable of type bdlf::NoOp
.
This section illustrates intended use of this component.
Asynchronous systems often provide callback-based interfaces that invoke supplied callbacks at later points in time, often when an event has occurred, like the receipt of a data packet on an internet socket. Occasionally, we may need to supply these interfaces with a callback even though there's nothing we need the callback to do. In these cases, it's often possible to supply a "no-op" callback that does nothing.
Consider, for example, the following hypothetical interface to an asynchronous system:
Suppose that we are writing a client for this system that does not need to be concerned about the status of ping
messages sent to the server, then we can use bdlf::NoOp
to ignore the acknowledgements:
Suppose that we are working with an asynchronous system whose interface requires a template for a callback instead of a bsl::function
.
Consider, for example, the following hypothetical interface to an asynchronous system:
Suppose that we are writing a client of this system that has no useful way to report the progress from the callback, then we can use bdlf::NoOp
to ignore the progress reports: