1
0
Fork 0

Move init variable in if.

This commit is contained in:
Pcornat 2025-12-13 12:32:01 +01:00
commit 1ebcaf6f97
Signed by: Pcornat
GPG key ID: E0326CC678A00BDD

View file

@ -3,8 +3,7 @@
namespace safe_cuda {
std::variant<std::unique_ptr<CUstream_st, streamDestroyType>, cudaError_t> create_stream() noexcept {
cudaStream_t stream = nullptr;
const cudaError_t error = cudaStreamCreate(&stream);
if (error != cudaSuccess) {
if (const cudaError_t error = cudaStreamCreate(&stream); error != cudaSuccess) {
return error;
}
return std::unique_ptr<CUstream_st, streamDestroyType>{ stream, cudaStreamDestroy };