Will consteval allow using static_assert on function arguments?

Will consteval allow to use static_assert on function arguments? No. Function arguments have never been, and will continue to not be, usable as constant expressions. There is a difference between something being constant evaluated and being usable as a constant-expression. consteval ensures that we’re in a constant evaluation context, but it does not also cause … Read more

C++ check if statement can be evaluated constexpr

Here’s another solution, which is more generic (applicable to any expression, without defining a separate template each time). This solution leverages that (1) lambda expressions can be constexpr as of C++17 (2) the type of a captureless lambda is default constructible as of C++20. The idea is, the overload that returns true is selected when … Read more

Why is operator!= removed in C++20 for many standard library types?

In C++20 the way that the relational operators work was changed, notably with the introduction of the spaceship <=> operator. In particular, If you only provide operator==, then a != b is rewritten to !(a == b). From [over.match.oper]/3.4: The rewritten candidate set is determined as follows: For the relational ([expr.rel]) operators, the rewritten candidates … Read more