Skip to content

QuantumGate::Result::Result

Karel Donk edited this page Sep 5, 2018 · 5 revisions

Creates a QuantumGate::Result object.

Signature

// Constructs a Result indicating failure by default.
Result() noexcept;
// Constructs a Result with the specified code. Does not throw when
// the result doesn't expect a value. Throws if the result expects
// a value and code is not an error.
Result(const ResultCode code) noexcept(!has_value_type<T>);
Result(const std::error_code& code) noexcept(!has_value_type<T>);
// Constructs a Result with the specified value. The error code is set
// to indicate success.
Result(const T& value) noexcept(std::is_nothrow_copy_constructible_v<std::optional<T>>);
Result(T&& value) noexcept(std::is_nothrow_move_constructible_v<std::optional<T>>);

Parameters

Name Description
code A QuantumGate::ResultCode or std::error_code with the error code to store. If the result expects a value (T is specified, e.g. Result<int>, Result<bool>) the code may only indicate failure. If the result doesn't expect a value (T is not specified, e.g. Result<>) the code may indicate success or failure. If these conditions aren't met a std::invalid_argument exception is thrown.
value The value to store for result types that expect a value (where T is specified, e.g. Result<int>, Result<bool>). When a value is stored the error code will indicate success.

Exceptions

May throw a std::invalid_argument exception when the code is invalid or when the value type's copy or move constructors throw.

Clone this wiki locally