ptal / expected

What did you expect?
113 stars 18 forks source link

Do we want to be able to do expected<exception_ptr, string> e{unexpect, 1}; ? #18

Closed viboes closed 10 years ago

viboes commented 10 years ago

Currently

expected<string> e{unexpect, 1}; 

fails to compile as exception_ptr is not constructible from int

If we want that this code is well formed, we need to make the expected_traits<E>::from_error a variadic function.

ptal commented 10 years ago

Why would we like it to be a valid code?

viboes commented 10 years ago

Because the fact that exception_ptr needs a specific factory is already hidden on the expected_traits. In particular the following works as expected accept an unexpected_type implicitly,

expected<string> e = make_unexpected(1); 

and the following works because there is an explicit constructor from cont char* to string

expected<int, string> e = {unexpect, "A"}; 
ptal commented 10 years ago

I think it's an issue of exception_ptr itself and not expected.

viboes commented 10 years ago

Ok, closed as invalid.