CHECK_NOTHROW_RET macro that returns the value inside the parathesis
Open
- Dominant language
- C++
- Stars
- 21.5k
- Forks
- 3.5k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 2
Description
**Description**
```
auto value = CHECK_NOTHROW_RET(function());
```
1. If `function()` throws, it would print the exception just like `CHECK_NOTHROW` currently does.
1. If `function()` does not throw, then it would assign the returned value to `auto value =`.
The main reason I want this is to both get the nice output on failure of `CHECK_NOTHROW` and get the returned value that can be used outside the check.
**Additional context**
Workaround that may or may not provide the same nice Catch2 output.
```
auto value = SomeType{};
CHECK_NOTHROW([&]() { value = functionCall(); }());
```
Contributor guide
Assessment
This issue has not been assessed yet.