Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decide whether to support non-generic customisable functions #30

Open
lewissbaker opened this issue Mar 20, 2022 · 0 comments
Open

Decide whether to support non-generic customisable functions #30

lewissbaker opened this issue Mar 20, 2022 · 0 comments

Comments

@lewissbaker
Copy link
Collaborator

lewissbaker commented Mar 20, 2022

Does it make sense to declare a function as customisable if it does not have any deducible parameter types?

e.g.

namespace foo {
  virtual bool some_func(size_t count) default { /* default implementation */ }
}

such that an application could later provide an override (every override must have that exact signature)

namespace foo {
  // shadows default implementation
  bool some_func(size_t count) override { /* override implementation */ }
}

This is not dissimilar to how an application is allowed to override the default global operator new, although the mechanism is a bit different due to the use of link-time overrides rather than compile-time overrides.

This could also potentially be paired with hidden friends to pick up different overrides:

namespace bar {
  struct X {
    operator size_t() const;
    friend bool foo::some_func(size_t size) override { /* override implementation */ }
  };
}

// This would find X's customisation (since it's an associated entity) and so would consider this an override.
// It would be ambiguous which overload to call if the other override declared above was also visible, however.
foo::some_func(X{}); 

This is a pretty obscure edge-case, however.

Maybe it is better to just require that customisable functions are actually templates, at least initially?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant