The C++ Build Insights SDK is compatible with Visual Studio 2017 and above. To see the documentation for these versions, set the Visual Studio Version selector control for this article to Visual Studio 2017 or Visual Studio 2019. It's found at the top of the table of contents on this page.

The MatchEventInMemberFunction function is used to match an event against the type described by the first parameter of a member function. The matched event is forwarded to the member function for further processing.


template <
    typename     TInterface,
    typename     TReturn,
    typename     TEvent,
    typename...  TExtraParams,
    typename...  TExtraArgs>
bool MatchEventInMemberFunction(
    const RawEvent&          event,
    TInterface*              objectPtr,
    TReturn (TInterface::*   memberFunc)(TEvent, TExtraParams...),
    TExtraArgs&&...          extraArgs);


The type that contains the member function.

The return type of the member function.

The type of the event to match.

The types of the extra parameters accepted by the member function along with the event type to match.

The types of the extra arguments that were passed to MatchEventInMemberFunction.

The event to match against the event type described by TEvent.

A pointer to an object on which memberFunc gets called.

The member function that describes the event type to match.

The arguments that get perfect-forwarded to memberFunc along with the event type parameter.

Return Value

A bool value that is true if matching was successful, or false otherwise.


The event type to use for the TEvent parameter can be selected from a list of capture classes. For a list of events and the capture classes you can use to match them, see event table.


void MyClass::Foo1(Function f) {}

void MyClass::Foo2(Compiler cl) {}

void MyClass::OnStartActivity(const EventStack& eventStack)
    // Let's assume eventStack contains:
    // [Compiler, BackEndPass, C2DLL, CodeGeneration, Thread, Function]

    auto& functionEvent = eventStack.Back(); // The Function event

    bool b1 = MatchEventInMemberFunction(
        functionEvent, this, &MyClass::Foo1);

    bool b2 = MatchEventInMemberFunction(
        functionEvent, this, &MyClass::Foo2);

    // b1: true because the first parameter of Foo1 is Function.
    // b2: false because the first parameter of Foo2 isn't Function.