Skip to content

Commit c9ec1da

Browse files
authored
Add default constructor to Ort::Status. (microsoft#25860)
### Description <!-- Describe your changes. --> Fix packaging pipelines ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> During CIs and local builds Ort::Status() gets inherited from the base due to using directives, however, that does not work for packaging pipelines. Having default ctor is important for storing Status in containers if needed.
1 parent 568ad20 commit c9ec1da

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

include/onnxruntime/core/session/onnxruntime_cxx_api.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,9 +725,7 @@ using AllocatedStringPtr = std::unique_ptr<char, detail::AllocatedFree>;
725725
* constructors to construct an instance of a Status object from exceptions.
726726
*/
727727
struct Status : detail::Base<OrtStatus> {
728-
using Base = detail::Base<OrtStatus>;
729-
using Base::Base;
730-
728+
Status() = default; // Same as with std::nullptr_t. But can be used in re-sizable containers and represent success.
731729
explicit Status(std::nullptr_t) noexcept {} ///< Create an empty object, must be assigned a valid one to be used
732730
explicit Status(OrtStatus* status) noexcept; ///< Takes ownership of OrtStatus instance returned from the C API.
733731
explicit Status(const Exception&); ///< Creates status instance out of exception

include/onnxruntime/core/session/onnxruntime_cxx_inline.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ inline Status Env::CopyTensors(const std::vector<Value>& src_tensors,
823823
return Status("Source and destination tensor vectors must have the same size", ORT_INVALID_ARGUMENT);
824824
}
825825
if (src_tensors.empty()) {
826-
return Status();
826+
return Status(nullptr);
827827
}
828828

829829
const OrtValue* const* src_tensors_ptr = reinterpret_cast<const OrtValue* const*>(src_tensors.data());

0 commit comments

Comments
 (0)