ned14 / status-code

Proposed SG14 status_code for the C++ standard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to clone a status_result<void>?

Tradias opened this issue · comments

Since Boost 1.79.0 I am struggling to clone a status_result<void> as the following code stopped compiling:

https://godbolt.org/z/Pezhxnrq8

#include <boost/outcome/experimental/status_result.hpp>
#include <optional>

namespace outcome = BOOST_OUTCOME_V2_NAMESPACE::experimental;

template <class T>
using Result = outcome::status_result<T>;

void b(std::optional<Result<void>>& result) {
    result.emplace(outcome::success());
}

And as a more general question: How to clone a status_result<void>? I was using a function like this so far:

    Result<void> clone_result(Result<void> result)
    {
        if (!result)
        {
            return std::move(result).assume_error().clone();
        }
        return outcome::success();
    }

Should be fixed in current trunk?

You're right the Boost 1.79 release is broken. I did post a patch to the mailing list.

And as a more general question: How to clone a status_result? I was using a function like this so far:

There are clone() free functions in trunk Outcome for basic results and basic outcomes with status codes in them.

Cool that works, thank you!