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

Conflicting implementations of map_imp in optional.hpp and expected.hpp #5

Closed
jeroen-dhollander opened this issue Feb 27, 2018 · 3 comments

Comments

@jeroen-dhollander
Copy link

Hey,

I am using both your implementation for optional and expected in the same project,
and I got compile issues when including both in the same file and using map on either of them:

// Minimal code to expose this:
#include "expected.hpp"
#include "optional.hpp"

void MyFunction()
{
    tl::optional<int> my_optional;
    my_optional.map([](int value) { return value + 1; });
}

Compilation failure:

optional.h: In instantiation of 'constexpr auto tl::optional<T>::map(F&&) & [with F = MyFunction()::<lambda(int)>; T = int]':
file.cc:14:56:   required from here
optional.h:770:20: error: call of overloaded 'map_impl(tl::optional<int>&, MyFunction()::<lambda(int)>)' is ambiguous
     return map_impl(*this, std::forward<F>(f));
            ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

The problem is that both optional and expected use a helper called map_impl, but with different implementations.

A simple solution I applied is simply renaming map_impl to optional_map_impl and expected_map_impl, respectively.

Jeroen

PS Thanks a lot for these libraries, I love them :)

@TartanLlama
Copy link
Owner

Whoops, I missed this issue, will get a fix up ASAP.

@TartanLlama
Copy link
Owner

Should be fixed in 74a422b and TartanLlama/expected@fcd7856

@jeroen-dhollander
Copy link
Author

Thanks

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