WE have the && operator, the || operator, but xor is only implemented
as '^' . And this causes a lot of confusion.

Let's take this case: 2 == 2 ^ 2 generates a logical operation instead of bitwise operation , therefore returning a true value.

What do yo think: Should the C++ standard have a xor logical operator? Why ?

Of course it's necessary. And useful. Look up it's uses.

As opposed to the other confusion which would result when trying to explain that ^^ does NOT do short-circuit evaluation like && and || does.

> Let's take this case: 2 == 2 ^ 2 generates a logical operation instead of bitwise operation
Huh?
2^2 is zero.

If you wanted to fake boolean operation, it would be (2!=0) ^ (2!=0) or ( a || b ) && !(a && b) it would still result in the answer zero.

> Should the C++ standard have a xor logical operator? Why ?
Why not NAND, NOR, XNOR etc etc?
There are semi-periodic moans about why ** wasn't implemented as "raise to power of".

It probably reflects the requirements of a few individuals seeking a clean and elegant language which implements the most used stuff well. They stopped adding features when it was useful.

As opposed to a committee designed monstrosity, where every last whim and prejudice is encoded into the language.

WE have the && operator, the || operator, but xor is only implemented
as '^' . And this causes a lot of confusion.

Let's take this case: 2 == 2 ^ 2 generates a logical operation instead of bitwise operation , therefore returning a true value.

What do yo think: Should the C++ standard have a xor logical operator? Why ?

Usually, noobs have problems with this. This is not mathematics. Its programming. Get use to its syntax.

I have been programming for 20 years and I can say I've missed the absence of a Logical XOR operator where as I know for a fact I would miss the absence of a Bitwise XOR operator.

Well. I don't miss a xor logic operator either, but my question is: "Wouldn't it be useful if we had one?".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.