nixd
Loading...
Searching...
No Matches
nixd
lib
Controller
CheckReturn.h
Go to the documentation of this file.
1
#pragma once
2
3
/// \brief Used for simplify early-returns.
4
///
5
/// const auto *foo = checkReturn(get(), nullptr)
6
#define CheckReturn(x, Ret) \
7
({ \
8
decltype(x) temp = (x); \
9
if (!temp) [[unlikely]] { \
10
return Ret; \
11
} \
12
temp; \
13
})
14
15
/// \brief Variant of `CheckReturn`, but returns default constructed `CheckTy`
16
#define CheckDefault(x) CheckReturn(x, CheckTy{})
Generated by
1.12.0