C conditional operator (‘?’) with empty second parameter [duplicate]
It is not permitted by the language C (as far as I know), but compilers such as gcc have the shortcut a?:c as an extension. a?:c means the same as a?a:c.
It is not permitted by the language C (as far as I know), but compilers such as gcc have the shortcut a?:c as an extension. a?:c means the same as a?a:c.
The += operator is implicitly defined like this: a += b turns into a = a + b;, same with the -= operator. (caveat: as Jeppe pointed out, if a is an expression, it is only evaluated once if you use a+=b, but twice with a=a+b) You cannot overload the += and -= operator separately. … Read more
return a && b means “return a if a is falsy, return b if a is truthy”. It is equivalent to if (a) return b; else return a;
In a declaration, it means it’s a pointer to a pointer: int **x; // declare x as a pointer to a pointer to an int When using it, it deferences it twice: int x = 1; int *y = &x; // declare y as a pointer to x int **z = &y; // declare z … Read more
The technical reason why is found in ยง12.3.2: A conversion function is never used to convert a (possibly cv-qualified) object to the (possibly cv-qualified) same object type (or a reference to it), to a (possibly cv-qualified) base class of that type (or a reference to it), or to (possibly cv-qualified) void. The rationale is (likely) … Read more
=~ is the operator testing a regular expression match. The expression /9eaf/ is a regular expression (the slashes // are delimiters, the 9eaf is the actual regular expression). In words, the test is saying “If the variable $tag matches the regular expression /9eaf/ …” and this match occurs if the string stored in $tag contains … Read more
Yes. ** is the exponentiation operator and is the equivalent of Math.pow. It was introduced in ECMAScript 2016 (ES7). For details, see the proposal and this chapter of Exploring ES2016.
The two forms make identical bytecode, as you can clearly verify: >>> import dis >>> dis.dis(compile(‘if x not in d: pass’, ”, ‘exec’)) 1 0 LOAD_NAME 0 (x) 3 LOAD_NAME 1 (d) 6 COMPARE_OP 7 (not in) 9 JUMP_IF_FALSE 4 (to 16) 12 POP_TOP 13 JUMP_FORWARD 1 (to 17) >> 16 POP_TOP >> 17 LOAD_CONST … Read more
Remember that negative numbers are stored as the two’s complement of the positive counterpart. As an example, here’s the representation of -2 in two’s complement: (8 bits) 1111 1110 The way you get this is by taking the binary representation of a number, taking its complement (inverting all the bits) and adding one. Two starts … Read more
This is, in effect, a way to check whether the expression e can be evaluated to be 0, and if not, to fail the build. The macro is somewhat misnamed; it should be something more like BUILD_BUG_OR_ZERO, rather than …ON_ZERO. (There have been occasional discussions about whether this is a confusing name.) You should read … Read more