Add variadic constructors for tl::unexpected

This commit is contained in:
Sy Brand
2022-11-24 12:52:29 +00:00
parent 4621a489bf
commit 4e86bddee3
2 changed files with 32 additions and 2 deletions
+13
View File
@@ -138,6 +138,19 @@ public:
constexpr explicit unexpected(E &&e) : m_val(std::move(e)) {}
template <class... Args, typename std::enable_if<std::is_constructible<
E, Args &&...>::value>::type * = nullptr>
constexpr explicit unexpected(Args &&...args)
: m_val(std::forward<Args>(args)...) {}
template <
class U, class... Args,
typename std::enable_if<std::is_constructible<
E, std::initializer_list<U> &, Args &&...>::value>::type * = nullptr>
constexpr explicit unexpected(std::initializer_list<U> l,
Args &&...args)
: m_val(l, std::forward<Args>(args)...) {}
constexpr const E &value() const & { return m_val; }
TL_EXPECTED_11_CONSTEXPR E &value() & { return m_val; }
TL_EXPECTED_11_CONSTEXPR E &&value() && { return std::move(m_val); }