I asked a question here about assert which is implemented in the standard as a macro, not a function.
This had caused me an issue because the way that assert>
If we look at [headers] paragraphs 5 and 6 we have
Names which are defined as macros in C shall be defined as macros in the C++ standard library, even if C grants license for implementation as functions. [ Note: The names defined as macros in C include the following:
assert
,offsetof
,setjmp
,va_arg
,va_end
, andva_start
. —end note ]Names that are defined as functions in C shall be defined as functions in the C++ standard library.
So, if it is defined as a macro in C, it will be a macro in C++. There are a couple of exceptions though. from [support.runtime] paragraphs 7 and 8
The header
and the header
shall not define a macro named
alignas
.The header
and the header
shall not define macros named
bool
,true
, orfalse
.
Although that those exceptions are covered by [headers]/7 as well
Identifiers that are keywords or operators in C++ shall not be defined as macros in C++ standard library headers.
There is also an exception that all classification macros defined in 7.12.3 Classification macros be overloaded by functions per [c.math]/10
The classification/comparison functions behave the same as the C macros with the corresponding names defined in 7.12.3, Classification macros, and 7.12.14, Comparison macros in the C Standard. Each function is overloaded for the three floating-point types, as follows:
int fpclassify(float x); bool isfinite(float x); bool isinf(float x); bool isnan(float x); bool isnormal(float x); bool signbit(float x); bool isgreater(float x, float y); bool isgreaterequal(float x, float y); bool isless(float x, float y); bool islessequal(float x, float y); bool islessgreater(float x, float y); bool isunordered(float x, float y); int fpclassify(double x); bool isfinite(double x); bool isinf(double x); bool isnan(double x); bool isnormal(double x); bool signbit(double x); bool isgreater(double x, double y); bool isgreaterequal(double x, double y); bool isless(double x, double y); bool islessequal(double x, double y); bool islessgreater(double x, double y); bool isunordered(double x, double y); int fpclassify(long double x); bool isfinite(long double x); bool isinf(long double x); bool isnan(long double x); bool isnormal(long double x); bool signbit(long double x); bool isgreater(long double x, long double y); bool isgreaterequal(long double x, long double y); bool isless(long double x, long double y); bool islessequal(long double x, long double y); bool islessgreater(long double x, long double y); bool isunordered(long double x, long double y);