#ifndef SRC_DAWN_COMMON_RESULT_H_
#define SRC_DAWN_COMMON_RESULT_H_
#include <cstddef>
#include <cstdint>
#include <memory>
#include <type_traits>
#include <utility>
#include <variant>
#include "dawn/common/Assert.h"
#include "dawn/common/Compiler.h"
namespace dawn {
template <typename T, typename E>
class Result;
Result<void, E>;
alignof_if_defined_else_default;
alignof_if_defined_else_default;
namespace detail {
enum PayloadType { … };
intptr_t MakePayload(const void* pointer, PayloadType type);
PayloadType GetPayloadType(intptr_t payload);
template <typename T>
static T* GetSuccessFromPayload(intptr_t payload);
template <typename E>
static E* GetErrorFromPayload(intptr_t payload);
constexpr static intptr_t kEmptyPayload = …;
}
Result<T *, E>;
Result<const T *, E>;
template <typename T>
class Ref;
Result<Ref<T>, E>;
template <typename T, typename E>
class [[nodiscard]] Result { … };
template <typename E>
Result<void, E>::Result() { … }
template <typename E>
Result<void, E>::Result(std::unique_ptr<E> error) : … { … }
template <typename E>
Result<void, E>::Result(Result<void, E>&& other) : … { … }
template <typename E>
Result<void, E>& Result<void, E>::operator=(Result<void, E>&& other) { … }
template <typename E>
Result<void, E>::~Result() { … }
template <typename E>
bool Result<void, E>::IsError() const { … }
template <typename E>
bool Result<void, E>::IsSuccess() const { … }
template <typename E>
void Result<void, E>::AcquireSuccess() { … }
template <typename E>
std::unique_ptr<E> Result<void, E>::AcquireError() { … }
namespace detail {
template <typename T>
T* GetSuccessFromPayload(intptr_t payload) { … }
template <typename E>
E* GetErrorFromPayload(intptr_t payload) { … }
}
template <typename T, typename E>
Result<T*, E>::Result(T* success) : … { … }
template <typename T, typename E>
Result<T*, E>::Result(std::unique_ptr<E> error)
: … { … }
template <typename T, typename E>
template <typename TChild>
Result<T*, E>::Result(Result<TChild*, E>&& other) : mPayload(other.mPayload) { … }
template <typename T, typename E>
template <typename TChild>
Result<T*, E>& Result<T*, E>::operator=(Result<TChild*, E>&& other) { … }
template <typename T, typename E>
Result<T*, E>::~Result() { … }
template <typename T, typename E>
bool Result<T*, E>::IsError() const { … }
template <typename T, typename E>
bool Result<T*, E>::IsSuccess() const { … }
template <typename T, typename E>
T* Result<T*, E>::AcquireSuccess() { … }
template <typename T, typename E>
std::unique_ptr<E> Result<T*, E>::AcquireError() { … }
template <typename T, typename E>
Result<const T*, E>::Result(const T* success)
: … { … }
template <typename T, typename E>
Result<const T*, E>::Result(std::unique_ptr<E> error)
: … { … }
template <typename T, typename E>
Result<const T*, E>::Result(Result<const T*, E>&& other) : … { … }
template <typename T, typename E>
Result<const T*, E>& Result<const T*, E>::operator=(Result<const T*, E>&& other) { … }
template <typename T, typename E>
Result<const T*, E>::~Result() { … }
template <typename T, typename E>
bool Result<const T*, E>::IsError() const { … }
template <typename T, typename E>
bool Result<const T*, E>::IsSuccess() const { … }
template <typename T, typename E>
const T* Result<const T*, E>::AcquireSuccess() { … }
template <typename T, typename E>
std::unique_ptr<E> Result<const T*, E>::AcquireError() { … }
template <typename T, typename E>
template <typename U>
Result<Ref<T>, E>::Result(Ref<U>&& success)
: mPayload(detail::MakePayload(success.Detach(), detail::Success)) { … }
template <typename T, typename E>
template <typename U>
Result<Ref<T>, E>::Result(const Ref<U>& success) : Result(Ref<U>(success)) { … }
template <typename T, typename E>
Result<Ref<T>, E>::Result(std::unique_ptr<E> error)
: … { … }
template <typename T, typename E>
template <typename U>
Result<Ref<T>, E>::Result(Result<Ref<U>, E>&& other) : mPayload(other.mPayload) { … }
template <typename T, typename E>
template <typename U>
Result<Ref<U>, E>& Result<Ref<T>, E>::operator=(Result<Ref<U>, E>&& other) { … }
template <typename T, typename E>
Result<Ref<T>, E>::~Result() { … }
template <typename T, typename E>
bool Result<Ref<T>, E>::IsError() const { … }
template <typename T, typename E>
bool Result<Ref<T>, E>::IsSuccess() const { … }
template <typename T, typename E>
Ref<T> Result<Ref<T>, E>::AcquireSuccess() { … }
template <typename T, typename E>
std::unique_ptr<E> Result<Ref<T>, E>::AcquireError() { … }
template <typename T, typename E>
Result<T, E>::Result(T success) : … { … }
template <typename T, typename E>
Result<T, E>::Result(std::unique_ptr<E> error) : … { … }
template <typename T, typename E>
Result<T, E>::~Result() { … }
template <typename T, typename E>
Result<T, E>::Result(Result<T, E>&& other) { … }
template <typename T, typename E>
Result<T, E>& Result<T, E>::operator=(Result<T, E>&& other) { … }
template <typename T, typename E>
bool Result<T, E>::IsError() const { … }
template <typename T, typename E>
bool Result<T, E>::IsSuccess() const { … }
template <typename T, typename E>
T Result<T, E>::AcquireSuccess() { … }
template <typename T, typename E>
std::unique_ptr<E> Result<T, E>::AcquireError() { … }
}
#endif