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

User-provided move constructor issue #97

Open
sparik opened this issue Dec 22, 2021 · 0 comments
Open

User-provided move constructor issue #97

sparik opened this issue Dec 22, 2021 · 0 comments

Comments

@sparik
Copy link

sparik commented Dec 22, 2021

Hi.

Looks like if a type is not trivially move-constructible, then tl::expected<T, ...> is not move-constructible at all. Is this behavior intended?

Here is an example tested with the current master branch and gcc 11.1

#include "expected.hpp"

struct user_provided_move {
        user_provided_move() = default;
        user_provided_move(user_provided_move&&) noexcept {}
};

struct defaulted_move {
        defaulted_move() = default;
        defaulted_move(defaulted_move&&) noexcept = default;
};

int main() {
        tl::expected<user_provided_move, int> t1;
        tl::expected<defaulted_move, int> t2;
        
        tl::expected<user_provided_move, int> tm1(std::move(t1));
        tl::expected<defaulted_move, int> tm2(std::move(t2)); // does not compile
}
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

No branches or pull requests

1 participant