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

Overloaded signatures don't seem to work or be tested #18

Open
Quuxplusone opened this issue Mar 31, 2019 · 2 comments
Open

Overloaded signatures don't seem to work or be tested #18

Quuxplusone opened this issue Mar 31, 2019 · 2 comments

Comments

@Quuxplusone
Copy link

https://godbolt.org/z/RcyhgH

#include <cxx_function.hpp>

int foo(int);

cxx_function::function<int(), int(int)> f = foo;
cxx_function::function<int(int), int()> g = foo;

My impression from the README is that this code is supposed to compile. It doesn't.
I don't see any test cases in test/ that try to use multiple signatures, so my working hypothesis is that the README is simply over-optimistically out-of-sync with what's actually implemented.

@Quuxplusone
Copy link
Author

...Oh wait, I mixed up my product types with my sum types. Presumably this is not supposed to compile, after all, because foo is not invokable with both signatures.

https://godbolt.org/z/-BXfP9 works OK.

int foo();
int foo(int);

cxx_function::function<int(), int(int)> f = [](auto... args) { return foo(args...); };
cxx_function::function<int(int), int()> g = [](auto... args) { return foo(args...); };

I still think there ought to be something for this in test/, though, and ideally a short example in the README.

@potswa
Copy link
Owner

potswa commented Mar 31, 2019

There are some testcases in constructible.cpp to ensure that certain overloads compile (or, like this one, SFINAE), but of course more and deeper testing would be better and welcome.

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

2 participants