TartanLlama / expected

C++11/14/17 std::expected with functional-style extensions

Home Page:https://tl.tartanllama.xyz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

User-provided move constructor issue

sparik opened this issue · comments

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
}