Date: Tue, 30 Jun 2026 16:48:56 +0200
To be honest: I think it is the wrong way. A change in the language for a single use case and not even the use case is fully covered.
The preprocessor is good, because it is flexible.
Combine your idea with reflection and metaprogramming.
Those are the tools for this stuff.
-----Ursprüngliche Nachricht-----
Von:Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]>
Gesendet:Di 30.06.2026 16:41
Betreff:[std-proposals] Redundify the preprocessor --- Part 1 ---- std::labelled
An:std-proposals <std-proposals_at_[hidden]>;
CC:Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>;
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?
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2026-06-30 14:53:05
