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

Can't call in-place unexpected constructor with more than one param

BMBurstein opened this issue · comments

Am I using this wrong, or is it a bug?

#include "tl/expected.hpp"

struct S {
    S(int) {}
    S(int,int) {}
};

int main() {
    tl::expected<int, S> ex1(tl::unexpect, 2);    // works
    tl::expected<int, S> ex2(tl::unexpect, 2, 2); // fails
}

It seems there is an appropriate constructor for expected (https://tl.tartanllama.xyz/en/latest/api/expected.html#_CPPv4IDpEN8expected8expectedEN2tl10unexpect_tEDpRR4Args), which forwards to the constructor for unexpected, which is missing the constructor taking Args...

Fixed in 4e86bdd