diff --git a/paddle/fluid/inference/api/paddle_infer_contrib.cc b/paddle/fluid/inference/api/paddle_infer_contrib.cc index 0d17e7ca6ce4fbf1a9d6000492fef3518f0b2190..171db0807e7de0ade3bd5303dd44ec82d4841535 100644 --- a/paddle/fluid/inference/api/paddle_infer_contrib.cc +++ b/paddle/fluid/inference/api/paddle_infer_contrib.cc @@ -215,8 +215,8 @@ struct Status::Impl { std::string msg; }; -Status::Status() noexcept : impl_(new Impl) {} -Status::Status(const Status& status) noexcept : impl_(new Impl) { +Status::Status() : impl_(std::make_shared()) {} +Status::Status(const Status& status) : impl_(std::make_shared()) { *impl_ = *status.impl_; } @@ -224,7 +224,7 @@ Status& Status::operator=(const Status& status) noexcept { *impl_ = *status.impl_; return *this; } -Status::Status(std::exception_ptr e) noexcept : impl_(new Impl) { +Status::Status(std::exception_ptr e) : impl_(std::make_shared()) { constexpr int kDefaultError{-1}; impl_->ec = kDefaultError; try { @@ -238,7 +238,7 @@ Status::Status(std::exception_ptr e) noexcept : impl_(new Impl) { impl_->msg = e.what(); } } -Status Status::OK() noexcept { return Status(); } +Status Status::OK() { return Status(); } bool Status::ok() const noexcept { return impl_->ec == 0; } Status::Code Status::code() const noexcept { return impl_->ec; } const std::string& Status::error_message() const noexcept { return impl_->msg; } diff --git a/paddle/fluid/inference/api/paddle_infer_contrib.h b/paddle/fluid/inference/api/paddle_infer_contrib.h index b0611dfe75f2ed73801c8feef6b4a9d51d4613bb..2598d5cd2d942ef42adf28396f1fe53922a8bab7 100644 --- a/paddle/fluid/inference/api/paddle_infer_contrib.h +++ b/paddle/fluid/inference/api/paddle_infer_contrib.h @@ -48,10 +48,10 @@ class Status { using Code = int; struct Impl; - Status() noexcept; - explicit Status(std::exception_ptr e) noexcept; + Status(); + explicit Status(std::exception_ptr e); - Status(const Status&) noexcept; + Status(const Status&); Status& operator=(const Status&) noexcept; Status& operator=(Status&&) = default; Status(Status&&) = default; @@ -61,7 +61,7 @@ class Status { /// /// \return A status which indicate ok. /// - static Status OK() noexcept; + static Status OK(); /// /// \brief Determine whether the status is ok.