| 235 | // Like `e.value()`, but throws using `throwExceptionFromExpected` (which is better, because it allows Python to see the proper error message), and also supports `T == void`. |
| 236 | template <typename T> |
| 237 | [[nodiscard]] decltype(auto) expectedValueOrThrow( T&& e ) |
| 238 | { |
| 239 | if ( e ) |
| 240 | { |
| 241 | if constexpr ( std::is_void_v<typename std::remove_cvref_t<T>::value_type> ) |
| 242 | return; |
| 243 | else |
| 244 | return *std::forward<T>( e ); |
| 245 | } |
| 246 | else |
| 247 | { |
| 248 | throwExceptionFromExpected( e.error() ); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | template<typename R, typename E, typename... Args> |
| 253 | auto decorateExpected( std::function<Expected<R, E>( Args... )>&& f ) -> std::function<R( Args... )> |
no test coverage detected