Recently I found a code where is used the keyword and
which working like &&
. So are they both the same or is there any specific condition to use it?
The C++ standard permits the token &&
to be used interchangeably with the token and
.
Not all compilers implement this correctly (some don't bother at all; others require the inclusion of a special header). As such, code using and
can be considered idiosyncratic.
The fact that the equivalence is at the token, rather than the operator, level means that since C++11 (where the language acquired the rvalue reference notation), you can arrange things (without recourse to the preprocessor) such that the statement
int and _int(string and vector);
is a valid function prototype. (It's eqivalent to int&& _int(string&& vector)
.)
As can be seen here, they're the same thing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With