> Substitution failure is not an error (SFINAE) refers to a situation in C++ where an invalid substitution of template parameters is not in itself an error.
https://en.m.wikipedia.org/wiki/Substitution_failure_is_not_...
> Up to C++17, there are four operators the operands of which are unevaluated: typeof, sizeof, decltype, and noexcept.
"typeof" should be "typeid". This confused me a bit as I thought the article was going to talk about a nonstandard predecessor to decltype.
The article was interesting, but its contents didn't really match it's title. It's not about unevaluated operands in general but just their use in SFINAE specifically. For example, sizeof is dismissed as not much use for SFINAE, which is true but it certainly has a lot of other uses! And if you read this article having not seen decltype before, I think you'd get the wrong impression about its range of uses.
Previous I have used this idiom:
#define MY_ASSERT(expr) do {} while (false && (expr))
Another possible alternative might be:
#define MY_ASSERT(expr) sizeof(expr)
#define MY_ASSERT(expr) do {} while (false && ((expr), false))
This doesn't require expr to be convertible to bool. #define MY_ASSERT(expr) ((void)(false && (expr)))
The problem the do-while idiom is that the macro result is not an expression, so it can’t be used in certain cases.sizeof accepts a type or an expression as its input, so it would compile successfully if expr were a type but not a valid expression (say, int).
Edit: I have probably seen it in concepts lite though, I just forgot about it.
This concept is operators that will never evaluate the expressions they operate on.
sizeof is the oldschool obvious one, sizeof(foo()) never runs the function foo. It's just a way of querying the static properties of an expression, asking specific things about its type in a way.
They're not new things in C++. sizeof has been around since the beginning.