/operator_alternative

C++ Alternative operator representations and some examples.

Primary LanguageC++

Before to start

When I see this, I was very shocked because I've never see this before and I never thought of it. You can look at this repo for more information about operator alternatives in CPP to enlarge your mind (:

Code examples

So you are still using && 🤔 You are just crazy, look at this alternative.

&& to 'and'

And yeah, I am using <% %> for { } like EJS

int main( )
<%
   auto username = "swenenzy";
   auto year = 2021;
   // Look at this i'm using 'and' instead of && very strange right?
   if ( username == "swenenzy" and year == 2021 ) <%
	   printf( "both sides are equal" );
   %>
%>

image_1

|| to 'or';

Why not?

int main( )
<%
   auto username = "swenenzy";
   auto year = 2021;
   if ( username == "swenenzy" or year == 2023 ) <%
	   printf( "one out of both correct\n" );
   %>
%>

image_2

How about includes?

You can use includes like this syntax.

%:include <iostream>

Reference table

Primary Alternative
&& and
&= and_eq
& bitand
| bitor
~ compl
! not
!= not_eq
|| or
|= or_eq
^ xor
^= xor_eq
{ <%
} %>
[ <:
] :>
# %:
## %:%:

CPPReference has more detailed documentation, I'm writing this repo because I haven't seen it on github before.

You can give me suggestions with PR or ISSUES for improving this repo.

Check out CPPReference!

This documentation is all tested on C+14 to C+21.

Peace out 🖖