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

Change Promise.thenPipe to use template types instead of std::function #181

Closed
wants to merge 5 commits into from
Closed

Conversation

murillo128
Copy link

@murillo128 murillo128 commented Jan 13, 2017

When compiling with Visual Studio 2015 I am getting the following compilation errors:

> src\FireWyrm\AlienWyrmling.cpp(125): error C2664: 'FB::Promise<FB::variant> FB::Promise<void>::thenPipe<FB::variant>(std::function<FB::variantPromise (void)>,std::function<FB::Promise<FB::variant> (std::exception_ptr)>) const': cannot convert argument 1 from 'FB::FireWyrm::AlienWyrmling::Invoke::<lambda_7d0129f19c4193e2d5fbf9013690dec1>' to 'std::function<FB::variantPromise (void)>'
>  src\FireWyrm\AlienWyrmling.cpp(125): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

It seems that msvc-14 is not able to cast lambda functions to std::functions that is what the thenPipe method expects.

This is a tentative (unproven and not tested on other c++ compilers) to try to address it.

The PR has two main changes:

  • Change the method parameters to template types that are automatically inferred by the compiler
  • Due to previous change, when calling with only 1 argument, the type of the second parameter cannot be inferred, and if set to null if fails as null don't have the expected methods. So I have duplicated the thenPipe methods in two one for success only callback and another with the success and fail callback

I am mostly sure that this PR is not ready for merging, but I hope it is worthy as a starting point.

@murillo128 murillo128 closed this Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant