Skip to content

What syntax to use member function/method with service delegate? #5

Description

@sfinktah

Following on from test and example code, s.registerDelegate(d) will fail if d is not a free function.

void test() {
//  Free function works fine
//  auto d = make_delegate(&myFreeFunction);

//  But member methods will create an error
    A a;
    auto d = make_delegate(&A::simple, a);

    Service s;
    s.registerDelegate(d);
//  Error (active)  a reference of type "ServiceDelegate &" (not
//  const-qualified) cannot be initialized with a value of type
//  "dlgt::delegate<void (A::*)()>"

//  Error   C2664   'void Service::registerDelegate(ServiceDelegate &)': cannot
//  convert argument 1 from 'dlgt::delegate<void (__cdecl A::* )(void)>' to
//  'ServiceDelegate &'

    s.notifyDelegate();
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions