| 140 | #endif |
| 141 | |
| 142 | template <class E> class unexpected { |
| 143 | public: |
| 144 | static_assert(!std::is_same<E, void>::value, "E must not be void"); |
| 145 | |
| 146 | unexpected() = delete; |
| 147 | constexpr explicit unexpected(const E &e) : m_val(e) {} |
| 148 | |
| 149 | constexpr explicit unexpected(E &&e) : m_val(std::move(e)) {} |
| 150 | |
| 151 | template <class... Args, typename std::enable_if<std::is_constructible< |
| 152 | E, Args &&...>::value>::type * = nullptr> |
| 153 | constexpr explicit unexpected(Args &&...args) |
| 154 | : m_val(std::forward<Args>(args)...) {} |
| 155 | template < |
| 156 | class U, class... Args, |
| 157 | typename std::enable_if<std::is_constructible< |
| 158 | E, std::initializer_list<U> &, Args &&...>::value>::type * = nullptr> |
| 159 | constexpr explicit unexpected(std::initializer_list<U> l, Args &&...args) |
| 160 | : m_val(l, std::forward<Args>(args)...) {} |
| 161 | |
| 162 | constexpr const E &value() const & { return m_val; } |
| 163 | TL_EXPECTED_11_CONSTEXPR E &value() & { return m_val; } |
| 164 | TL_EXPECTED_11_CONSTEXPR E &&value() && { return std::move(m_val); } |
| 165 | constexpr const E &&value() const && { return std::move(m_val); } |
| 166 | |
| 167 | private: |
| 168 | E m_val; |
| 169 | }; |
| 170 | |
| 171 | #ifdef __cpp_deduction_guides |
| 172 | template <class E> unexpected(E) -> unexpected<E>; |
no outgoing calls