Lines Matching defs:std

56   virtual std::string message() const {
57 std::string Msg;
63 /// Convert this error to a std::error_code.
66 /// using std::error_code. It will be removed in the future.
67 virtual std::error_code convertToErrorCode() const = 0;
137 /// [](std::unique_ptr<OtherError> M) -> Error {
143 /// return Error(std::move(M));
193 *this = std::move(Other);
198 Error(std::unique_ptr<ErrorInfoBase> Payload) {
303 std::unique_ptr<ErrorInfoBase> takePayload() {
304 std::unique_ptr<ErrorInfoBase> Tmp(getPtr());
331 return Error(std::make_unique<ErrT>(std::forward<ArgTs>(Args)...));
377 std::error_code convertToErrorCode() const override;
383 ErrorList(std::unique_ptr<ErrorInfoBase> Payload1,
384 std::unique_ptr<ErrorInfoBase> Payload2) {
387 Payloads.push_back(std::move(Payload1));
388 Payloads.push_back(std::move(Payload2));
402 E1List.Payloads.push_back(std::move(Payload));
413 return Error(std::unique_ptr<ErrorList>(
417 std::vector<std::unique_ptr<ErrorInfoBase>> Payloads;
424 return ErrorList::join(std::move(E1), std::move(E2));
437 static const bool isRef = std::is_reference<T>::value;
439 using wrap = std::reference_wrapper<typename std::remove_reference<T>::type>;
441 using error_type = std::unique_ptr<ErrorInfoBase>;
444 using storage_type = typename std::conditional<isRef, wrap, T>::type;
448 using reference = typename std::remove_reference<T>::type &;
449 using const_reference = const typename std::remove_reference<T>::type &;
450 using pointer = typename std::remove_reference<T>::type *;
451 using const_pointer = const typename std::remove_reference<T>::type *;
475 typename std::enable_if<std::is_convertible<OtherT, T>::value>::type
483 new (getStorage()) storage_type(std::forward<OtherT>(Val));
487 Expected(Expected &&Other) { moveConstruct(std::move(Other)); }
493 typename std::enable_if<std::is_convertible<OtherT, T>::value>::type
495 moveConstruct(std::move(Other));
503 typename std::enable_if<!std::is_convertible<OtherT, T>::value>::type * =
505 moveConstruct(std::move(Other));
510 moveAssign(std::move(Other));
556 return HasError ? Error(std::move(*getErrorStorage())) : Error::success();
602 new (getStorage()) storage_type(std::move(*Other.getStorage()));
604 new (getErrorStorage()) error_type(std::move(*Other.getErrorStorage()));
614 new (this) Expected(std::move(Other));
708 std::string Str;
733 return std::move(*ValOrErr);
738 std::string Str;
769 std::string Str;
784 &std::remove_reference<HandlerT>::type::operator())> {};
794 static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) {
808 static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) {
815 /// Specialization for functions of the form 'Error (std::unique_ptr<ErrT>)'.
817 class ErrorHandlerTraits<Error (&)(std::unique_ptr<ErrT>)> {
824 static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) {
826 std::unique_ptr<ErrT> SubE(static_cast<ErrT *>(E.release()));
827 return H(std::move(SubE));
831 /// Specialization for functions of the form 'void (std::unique_ptr<ErrT>)'.
833 class ErrorHandlerTraits<void (&)(std::unique_ptr<ErrT>)> {
840 static Error apply(HandlerT &&H, std::unique_ptr<ErrorInfoBase> E) {
842 std::unique_ptr<ErrT> SubE(static_cast<ErrT *>(E.release()));
843 H(std::move(SubE));
869 /// 'RetT (std::unique_ptr<ErrT>)'.
871 class ErrorHandlerTraits<RetT (C::*)(std::unique_ptr<ErrT>)>
872 : public ErrorHandlerTraits<RetT (&)(std::unique_ptr<ErrT>)> {};
875 /// 'RetT (std::unique_ptr<ErrT>) const'.
877 class ErrorHandlerTraits<RetT (C::*)(std::unique_ptr<ErrT>) const>
878 : public ErrorHandlerTraits<RetT (&)(std::unique_ptr<ErrT>)> {};
880 inline Error handleErrorImpl(std::unique_ptr<ErrorInfoBase> Payload) {
881 return Error(std::move(Payload));
885 Error handleErrorImpl(std::unique_ptr<ErrorInfoBase> Payload,
888 return ErrorHandlerTraits<HandlerT>::apply(std::forward<HandlerT>(Handler),
889 std::move(Payload));
890 return handleErrorImpl(std::move(Payload),
891 std::forward<HandlerTs>(Handlers)...);
905 std::unique_ptr<ErrorInfoBase> Payload = E.takePayload();
912 std::move(R),
913 handleErrorImpl(std::move(P), std::forward<HandlerTs>(Hs)...));
917 return handleErrorImpl(std::move(Payload), std::forward<HandlerTs>(Hs)...);
925 cantFail(handleErrors(std::move(E), std::forward<HandlerTs>(Handlers)...));
931 cantFail(std::move(E));
965 std::forward<HandlerTs>(Handlers)...))
966 return std::move(Err);
986 inline std::string toString(Error E) {
987 SmallVector<std::string, 2> Errors;
988 handleAllErrors(std::move(E), [&Errors](const ErrorInfoBase &EI) {
1002 handleAllErrors(std::move(Err), [](const ErrorInfoBase &) {});
1014 return std::move(*E);
1027 consumeError(std::move(Err));
1094 /// This class wraps a std::error_code in a Error.
1098 /// std::error_codes.
1100 friend Error errorCodeToError(std::error_code);
1105 void setErrorCode(std::error_code EC) { this->EC = EC; }
1106 std::error_code convertToErrorCode() const override { return EC; }
1114 ECError(std::error_code EC) : EC(EC) {}
1116 std::error_code EC;
1120 /// for Error values where no sensible translation to std::error_code exists.
1122 /// sensible conversion to std::error_code is available, as attempts to convert
1125 std::error_code inconvertibleErrorCode();
1127 /// Helper for converting an std::error_code to a Error.
1128 Error errorCodeToError(std::error_code EC);
1130 /// Helper for converting an ECError to a std::error_code.
1134 std::error_code errorToErrorCode(Error Err);
1140 return std::move(*EO);
1146 return errorToErrorCode(std::move(Err));
1147 return std::move(*E);
1179 StringError(std::error_code EC, const Twine &S = Twine());
1182 StringError(const Twine &S, std::error_code EC);
1185 std::error_code convertToErrorCode() const override;
1187 const std::string &getMessage() const { return Msg; }
1190 std::string Msg;
1191 std::error_code EC;
1197 inline Error createStringError(std::error_code EC, char const *Fmt,
1199 std::string Buffer;
1205 Error createStringError(std::error_code EC, char const *Msg);
1207 inline Error createStringError(std::error_code EC, const Twine &S) {
1212 inline Error createStringError(std::errc EC, char const *Fmt,
1214 return createStringError(std::make_error_code(EC), Fmt, Vals...);
1237 Error takeError() { return Error(std::move(Err)); }
1239 std::error_code convertToErrorCode() const override;
1246 std::unique_ptr<ErrorInfoBase> E) {
1251 Err = std::move(E);
1252 Line = std::move(LineNum);
1256 std::unique_ptr<ErrorInfoBase> Payload;
1257 handleAllErrors(std::move(E),
1258 [&](std::unique_ptr<ErrorInfoBase> EIB) -> Error {
1259 Payload = std::move(EIB);
1263 std::unique_ptr<FileError>(new FileError(F, Line, std::move(Payload))));
1266 std::string FileName;
1268 std::unique_ptr<ErrorInfoBase> Err;
1274 return FileError::build(F, Optional<size_t>(), std::move(E));
1280 return FileError::build(F, Optional<size_t>(Line), std::move(E));
1283 /// Concatenate a source file path and/or name with a std::error_code
1285 inline Error createFileError(const Twine &F, std::error_code EC) {
1290 /// std::error_code to form an Error object.
1291 inline Error createFileError(const Twine &F, size_t Line, std::error_code EC) {
1304 ExitOnError(std::string Banner = "", int DefaultErrorExitCode = 1)
1305 : Banner(std::move(Banner)),
1309 void setBanner(std::string Banner) { this->Banner = std::move(Banner); }
1312 void setExitCodeMapper(std::function<int(const Error &)> GetExitCode) {
1313 this->GetExitCode = std::move(GetExitCode);
1317 void operator()(Error Err) const { checkError(std::move(Err)); }
1323 return std::move(*E);
1337 logAllUnhandledErrors(std::move(Err), errs(), Banner);
1342 std::string Banner;
1343 std::function<int(const Error &)> GetExitCode;
1353 return Error(std::unique_ptr<ErrorInfoBase>(