libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
expected.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2022 Kitsune Ral <Kitsune-Ral@users.sf.net>
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <expected>
7
8namespace Quotient {
9
10template <typename T, typename E>
11 requires (!std::is_same_v<T, E>)
12class [[deprecated("Use std::expected instead")]] Expected : public std::expected<T, E> {
13public:
14 using std::expected<T, E>::expected;
15
16 template <std::convertible_to<E> X>
17 explicit(false) Expected(X&& x) : std::expected<T, E>(std::unexpect, std::forward<X>(x))
18 {}
19
20 T&& move_value_or(T&& fallback)
21 {
22 if (this->has_value())
23 return std::move(this->value());
24 return std::move(fallback);
25 }
26};
27
28} // namespace Quotient
explicit(false) Expected(X &&x)
Definition expected.h:17
T && move_value_or(T &&fallback)
Definition expected.h:20