Skip to content

Comments

Added explicitly defaulted constructor to error class#4

Open
FrankHB wants to merge 1 commit intoPsiphon-Inc:masterfrom
FrankHB:patch-1
Open

Added explicitly defaulted constructor to error class#4
FrankHB wants to merge 1 commit intoPsiphon-Inc:masterfrom
FrankHB:patch-1

Conversation

@FrankHB
Copy link

@FrankHB FrankHB commented Dec 2, 2019

Since the first template argument of expected can not always meet is_nothrow_move_constructible (e.g. HTTPParams), class Error (used with expected) needs to meet is_nothrow_move_constructible to prevent the assignment operator of expect being defined as deleted. This actually fixes the build failure with updated expected-lite 0.3.0.
Note that Error(Error&&) = default; could be sufficient as it would be implicit noexcept. The explicit noexcept should make the intention more explicit.

Since the first template argument of `expected` can not always meet `is_nothrow_move_constructible` (e.g. `HTTPParams`), class `Error` (used with `expected`) needs to meet `is_nothrow_move_constructible` to prevent [the assignment operator of `expect` being defined as deleted](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0323r9.html#expected.object.assign). This actually fixes the build failure with updated expected-lite 0.3.0.
Note that `Error(Error&&) = default;` could be sufficient as it would be implicit `noexcept`. The explicit `noexcept` should make the intention more explicit.
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

Successfully merging this pull request may close these issues.

1 participant