make_unexpected isn't compiled in VS19 C++20
sergeypolkovnikov opened this issue · 0 comments
sergeypolkovnikov commented
environment: Microsoft Visual Studio Enterprise 2019 Version 16.11.2
compiler flag: /std:c++20
the following code is not compiled (in C++17 it compiles successfully)
check::Expected makeError(int const code, std::string description)
{
return tl::make_unexpected(check::Error{code, std::move(description)});
// Error C2440 'return': cannot convert from 'tl::unexpected<E>' to 'tl::expected<check::Success,check::Error>'
}
definitions:
struct Success
{
};
struct Error
{
explicit Error(Error&&) = default; // to delete copy ctor
Error(int code, std::string description) :
code(code),
description(std::move(description))
{}
int code = 0;
std::string description;
};
using Expected = tl::expected<Success, Error>;