ptal / expected

What did you expect?
113 stars 18 forks source link

Why does `error_type` need to be default constructible? #88

Closed russellmcc closed 8 years ago

russellmcc commented 8 years ago

Would it be possible to craft expected to not require a default constructible error_type?

viboes commented 8 years ago

Yes, I must adapt it to the newest proposal that defaults to T() if T is default constructible. Beside in the defautl constructor, is it used in another location?

Do you have cases where E() is not default constructible?

russellmcc commented 8 years ago

Yes, most constructors initialize base_type before doing the work of constructing, which means that error_type is default-constructed. For example, in the move constructor for value_type.

viboes commented 8 years ago

It was decided that expected<T,E> would default to T if T is default constructible.

This commit try to fix this. https://github.com/ptal/expected/commit/5639527584417399362f984f23893dd538dbf5ee