Date: Wed, 24 Jun 2026 22:33:08 +0100
Instead of doing this:
#define ASSERT_EQ(a, b) \
do \
{ \
if ( (a) == (b) ) break; \
\
std::fprintf(stderr, #a " != " #b " at %s:%d\n", \
__FILE__, __LINE__); \
std::abort(); \
} while (0)
Wouldn't it be nice to be able to do this:
#define ASSERT_EQ(a, b) \\\
do
{
if ( (a) == (b) ) break;
std::fprintf(stderr, #a " != " #b " at %s:%d\n",
__FILE__, __LINE__);
std::abort();
} while (0)
\\\
I'm told back in the 1990's, a guy called Andrew Myers made a patch
for GNU gcc so that you could do:
#begin define swap(x,y,T)
do {
T temp = x;
x = y;
y = temp;
} while (0)
#end
Whether we use three backslashes or "'#begin define", this should be
standardised in C++29.
#define ASSERT_EQ(a, b) \
do \
{ \
if ( (a) == (b) ) break; \
\
std::fprintf(stderr, #a " != " #b " at %s:%d\n", \
__FILE__, __LINE__); \
std::abort(); \
} while (0)
Wouldn't it be nice to be able to do this:
#define ASSERT_EQ(a, b) \\\
do
{
if ( (a) == (b) ) break;
std::fprintf(stderr, #a " != " #b " at %s:%d\n",
__FILE__, __LINE__);
std::abort();
} while (0)
\\\
I'm told back in the 1990's, a guy called Andrew Myers made a patch
for GNU gcc so that you could do:
#begin define swap(x,y,T)
do {
T temp = x;
x = y;
y = temp;
} while (0)
#end
Whether we use three backslashes or "'#begin define", this should be
standardised in C++29.
Received on 2026-06-24 21:33:21
