Date: Wed, 1 Jul 2026 15:41:49 +0100
On 30/06/2026 15:41, Frederick Virchanza Gotham via Std-Proposals wrote:
> If the verb 'redundify' gets added to the English dictionary in the
> coming year, you know it was me who started it.
>
> I think we can work toward making the preprocessor redundant, but
> first we need 'std::labelled'.
>
> So when you have a function signature as follows:
>
> void Func( std::labelled<bool> );
>
> Under the hood it gets compiled to:
>
> void Func( bool, char const * );
>
> And when you invoke it as follows:
>
> Func( current_iterator != container.end() );
>
> The invocation gets compiled under the hood as:
>
> Func( current_iterator != container.end(), "current_iterator !=
> container.end()" );
>
> This would do away with macros such as the following:
>
> #define ASSERT_TRUE(condition) \
> do { \
> if (!(condition)) { \
> std::cerr << "Assertion failed at " << __FILE__ << ":" \
> << __LINE__ << "\n" \
> << "Expected true, but evaluated to false.\n" \
> << "Expression: " << #condition << std::endl; \
> std::abort(); /* Or trigger a breakpoint/test failure */ \
> } \
> } while (false)
>
> because they can be re-written as:
>
> inline void AssertTrue(
> std::labelled<bool> condition,
> const std::source_location location = std::source_location::current()
> ) {
> if (!condition.value()) {
> std::cerr << "Assertion failed at " <<
> location.file_name() << ":"
> << location.line() << "\n"
> << "Expected true, but evaluated to false.\n"
> << "Expression: " << condition.c_str() << std::endl;
> std::abort(); /* Or trigger a breakpoint/test failure */
> }
> }
>
> What do you reckon?
If you're using macros, you can check at compile time, I wrote a compile_assert proposal.
std::abort() could be considered a functional safety risk if it gets in a deployed application.
C++ compile_assert P4021
https://wg21.link/P4021
Which compiler are you using?
Regards, Jonathan
> If the verb 'redundify' gets added to the English dictionary in the
> coming year, you know it was me who started it.
>
> I think we can work toward making the preprocessor redundant, but
> first we need 'std::labelled'.
>
> So when you have a function signature as follows:
>
> void Func( std::labelled<bool> );
>
> Under the hood it gets compiled to:
>
> void Func( bool, char const * );
>
> And when you invoke it as follows:
>
> Func( current_iterator != container.end() );
>
> The invocation gets compiled under the hood as:
>
> Func( current_iterator != container.end(), "current_iterator !=
> container.end()" );
>
> This would do away with macros such as the following:
>
> #define ASSERT_TRUE(condition) \
> do { \
> if (!(condition)) { \
> std::cerr << "Assertion failed at " << __FILE__ << ":" \
> << __LINE__ << "\n" \
> << "Expected true, but evaluated to false.\n" \
> << "Expression: " << #condition << std::endl; \
> std::abort(); /* Or trigger a breakpoint/test failure */ \
> } \
> } while (false)
>
> because they can be re-written as:
>
> inline void AssertTrue(
> std::labelled<bool> condition,
> const std::source_location location = std::source_location::current()
> ) {
> if (!condition.value()) {
> std::cerr << "Assertion failed at " <<
> location.file_name() << ":"
> << location.line() << "\n"
> << "Expected true, but evaluated to false.\n"
> << "Expression: " << condition.c_str() << std::endl;
> std::abort(); /* Or trigger a breakpoint/test failure */
> }
> }
>
> What do you reckon?
If you're using macros, you can check at compile time, I wrote a compile_assert proposal.
std::abort() could be considered a functional safety risk if it gets in a deployed application.
C++ compile_assert P4021
https://wg21.link/P4021
Which compiler are you using?
Regards, Jonathan
Received on 2026-07-01 14:41:53
