blob: 7d1f82aeb2e0111b0b5e16658d3438ee03e3f723 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
//===-- A data structure for returning an error or a value ------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SUPPORT_ERROR_OR_RESULT_H
#define LLVM_LIBC_SUPPORT_ERROR_OR_RESULT_H
#include "src/__support/CPP/expected.h"
namespace __llvm_libc {
template <class T> using ErrorOr = cpp::expected<T, int>;
using Error = cpp::unexpected<int>;
// template <typename T> struct ErrorOr {
// union {
// T value;
// int error;
// };
// bool is_error;
// constexpr ErrorOr(T value) : value(value), is_error(false) {}
// constexpr ErrorOr(int error, bool is_error)
// : error(error), is_error(is_error) {}
// constexpr bool has_error() { return is_error; }
// constexpr operator bool() { return is_error; }
// constexpr operator T() { return value; }
// };
} // namespace __llvm_libc
#endif // LLVM_LIBC_SUPPORT_ERROR_OR_RESULT_H
|