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

Improvement expected #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Improvement expected #25

wants to merge 3 commits into from

Conversation

MimiXav
Copy link

@MimiXav MimiXav commented Dec 20, 2021

No description provided.

Copy link
Contributor

@etnKlendathu etnKlendathu left a 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;
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, no copy here

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&;
Copy link
Contributor

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;
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

No copy at all

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