-
Notifications
You must be signed in to change notification settings - Fork 6
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
Improvement expected #25
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I need to decline it.
@@ -33,55 +35,56 @@ template <typename T, typename ErrorT = std::string> | |||
class Expected | |||
{ | |||
public: | |||
constexpr Expected() = delete; | |||
constexpr Expected() = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, you cant to have default ctor
|
||
Expected(const Expected&) = delete; | ||
Expected& operator=(const Expected&) = delete; | ||
Expected(const Expected& other) = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, no copy here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why should copy not be allowed?
constexpr const T&& value() const&& noexcept; | ||
constexpr T&& value() && noexcept; | ||
constexpr const ErrorT& error() const& noexcept; | ||
constexpr const T& value() const&; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove noexcept?
ErrorT m_error; | ||
}; | ||
bool m_isError = false; | ||
std::variant<T, ErrorT> m_value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not union? this is more efficient type here
template <typename UnErrorT> | ||
Expected(Unexpected<UnErrorT>&& unex) noexcept; | ||
template <typename UnErrorT> | ||
Expected(const Unexpected<UnErrorT>& unex) noexcept; | ||
|
||
Expected(const Expected&) = delete; | ||
Expected& operator=(const Expected&) = delete; | ||
Expected(const Expected& other) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No copy at all
No description provided.