Skip to content

Commit c22969c

Browse files
author
Clément Metz
committed
Improved constexpr sections evaluation at compile time
Addressed @ZXShady comments
1 parent 60cb3d3 commit c22969c

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/catch2/internal/catch_constexpr_section.hpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,7 @@ namespace Catch {
2121
struct ConstexprSection {
2222
template <typename Callable>
2323
ConstexprSection( Callable callable ) {
24-
static_assert(
25-
[&] // error: CONSTEXPR_SECTION failure. Check the compiler
26-
// output to find the cause. You can make the section a
27-
// SECTION to investigate at runtime.
28-
{
29-
callable();
30-
return true;
31-
}(),
32-
"compile time section error" );
24+
static_assert( ( callable(), true ), "CONSTEXPR_SECTION failure" );
3325
addFakeAssertion();
3426
callable();
3527
}
@@ -51,8 +43,7 @@ namespace Catch {
5143
#else
5244
# define INTERNAL_CATCH_CONSTEXPR_SECTION( ... ) \
5345
static_assert( false, "C++17 is required for CONSTEXPR_SECTION" ); \
54-
if ( false ) { \
55-
} else
46+
if ( false )
5647
#endif
5748

5849
#endif // CATCH_CONSTEXPR_SECTION_HPP_INCLUDED

0 commit comments

Comments
 (0)