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

Refactor/result bind #101

Merged
merged 2 commits into from
Jun 7, 2019

Conversation

MBoldyrev
Copy link
Contributor

Description of the Change

Now the bound transformation function may return one of: Result, Value or any other unwrapped value that is treated like a Value. Also, a rvalue-reference binding specialization is added. Two functions to convert a Result's Error or Value to boost::optional are added.

Benefits

Hopefully allows to write a simpler code.

Possible Drawbacks

More code to maintain.

Usage Examples or Tests [optional]

Alternate Designs [optional]

@MBoldyrev MBoldyrev requested review from muratovv and igor-egorov June 5, 2019 06:45
@MBoldyrev MBoldyrev self-assigned this Jun 5, 2019
Copy link

@igor-egorov igor-egorov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we do really need that change.
Doesn't look so easy for understanding and maintaining.

constexpr bool isError = std::is_base_of<ErrorBase, T>::value;

/**
* A struct that provides the result type conversion for bind operator.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Suggested change
* A struct that provides the result type conversion for bind operator.
* A struct that provides the result of type conversion for bind operator.

* function outcome and former Result error type, and a method to convert
* transformation function outcome to this type.
*/
template <typename Transformed, typename ErrorType, typename = void>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typename = void - is it needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is needed for partial specialisation (please see below)

@MBoldyrev
Copy link
Contributor Author

I am not sure if we do really need that change.

It is a standalone part of changes in #84, which was taken into a separate PR (this one) to alleviate that change that became rather big.

@MBoldyrev MBoldyrev force-pushed the refactor/result-bind branch from fa3bf42 to 4429ea9 Compare June 7, 2019 08:34
@MBoldyrev MBoldyrev merged commit a5b5f64 into hyperledger-iroha:master Jun 7, 2019
@MBoldyrev MBoldyrev deleted the refactor/result-bind branch June 7, 2019 08:34
nvzhu pushed a commit to soramitsu/soramitsu-iroha that referenced this pull request Jan 9, 2024
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.

3 participants