template<class T, class Aggregator>
struct AZ::EBusReduceResult< T &, Aggregator >
Aggregates results returned by all handlers of an EBus event. Also puts the aggregated value into the input value that is passed by reference. You can use this structure to add results, apply a logical AND to results, and so on.
- Template Parameters
-
T | The output type of the aggregator. |
Aggregator | A function object that aggregates results. The return type must match T. For examples of function objects that you can use as aggregators, see functional_basic.h. |
The following example replaces the value returned by a handler with the sum of the value and previous handler return values.
int myExistingInt = 5;
MyBus::BroadcastResult(result, &MyBus::Events::GetANumber);
AZ_Printf("%d", result.value);
The following example determines whether all handlers, including the latest handler, return true. Also replaces the latest handler result with the aggregated result.
bool myExistingBool = true;
MyBus::BroadcastResult(result, &MyBus::Events::IsDoneDoingThing);
AZ_Printf("%d", myExistingBool);