....the conditional logic....
- The syntax looks more like standard C++ code and less like preprocessor directives
- Rather than writing the preprocessor conditional inclusion syntax like #ifdef and #endif at the beginning of each line, which breaks the flow of code if the code is already nested, this syntax can be written directly into the regular C++ code.
Here is how I would rewrite most of the example from the Conditional Inclusion page here (
https://en.cppreference.com/w/cpp/preprocessor/conditional) using this new syntax:
#define ABCD 2
#include <iostream>
int main()
{
condexpr if (ABCD){
std::cout << "1: yes\n";}
else
{
std::cout << "1: no\n";}
condexpr if (!ABCD)
{
std::cout << "2: no1\n";}
elif (ABCD == 2)
{
std::cout << "2: yes\n";}
else
{
std::cout << "2: no2\n";}
condexpr if (!(DCBA) && (ABCD < 2*4-3))
{
std::cout << "3: yes\n";}
condexpr if (CPU)
{
std::cout << "4: no1\n";}
elif (GPU)
{
std::cout << "4: no2\n";}
elif (!RAM)
{
std::cout << "4: yes\n"; }
else
{
std::cout << "4: no!\n";
}
}