When compiling our codebase with clang we were getting the following
error:
GSL/tests/algorithm_tests.cpp:198:58: warning: catch handler catches by
value; should catch by reference instead
[misc-throw-by-value-catch-by-reference]
CHECK_THROWS_AS(copy(src_span_dyn, dst_span_static), fail_fast);
^
Looking at the catch source code exceptions were being caught by value.
One could have it designed so that users might say:
CHECK_THROWS_AS(copy(src_span_dyn, dst_span_static), fail_fast&);
But I don't think this is the intent and looking at the Catch tests
itself looks like this macro does not expect the reference:
REQUIRE_THROWS_AS( thisThrows(), std::domain_error );
CHECK_THROWS_AS( thisDoesntThrow(), std::domain_error );
This commit makes Catch catch exceptions by reference instead of by
value.
Effectively a revert of previous commit, fixing #542, where this was
added to stop linters complaining about `REQUIRE_THROWS_AS` used like
`REQUIRE_THROWS_AS(expr, std::exception);`, which would be slicing the
caught exception. Now it is user's responsibility to pass us proper
exception type.
Closes#833 which wanted to add `typename`, so that the construct works
in a template, but that would not work with MSVC and older GCC's, as
having `typename` outside of a template is allowed only from C++11
onward.