Title: Theory / Unimportant / CS / Programming / C++ / Manual / Norm / 10 Expression;
Tags: seen_description computer_to_instruction FromInstruction automatedNewLineAfterCommaSpace hasNotNewEffectReturnsMeaning

Instruction: nullptr
Page: 172
Language: C++
Chapter: 7
Section: 2.2
Returns: a pointer that does not point to an object
Typ: foo* for any type foo

Instruction: (cond)?foo:bar;
Page: 259, 275
Effect: Evaluate cond, if its true evaluate foo otherwise bar.
Language: C++
Chapter: 10, 11
Section: 3.1, 1.3
Typ: If both foo and bar are lvalue, then lvalue.
Type of foo and bar if it's the same
Name: Ternary operator/conditional expression

Instruction: f(
  expr_1,
  ...,
  expr_n
)
Page: 259
Effect: Evaluate each expr_i in some undefined order, to their results val_1, ..., val_n. Execute f on val_1, ..., val_n
Language: C++
Chapter: 10
Section: 3.1
Returns: The value returned by the code of f
Name: Function call

Instruction: expr_1 = expr_2
Page: 259
Effect: Compute expr_1 and expr_2 in a non determined order
Assign the value of expr_2 to expr_1
Language: C++
Chapter: 10
Section: 3.1
Returns: same as expr_2
Assuming: expr_1 evaluates to a l value
Name: Assignment

Instruction: expr_1, expr_2
Page: 259
Effect: Evaluate expr_1, then expr_2
Language: C++
Chapter: 10
Section: 3.1
Returns: same as expr_2
Assuming: expr_1 evaluates to a l value

Name: Short-circuit evaluation
Definition: The fact that for built-in type, && and || does not evaluate the second value if the first is sufficient
Page: 260
Chapter: 10
Section: 3.2
Context: C++

Question: How is interpreted (0 <= x <= 99)
Answer: (0 <= x) <= 99, hence true
Page: 261
Chapter: 10
Section: 3.3

Question: Why to write "7==a" instead of "a==7"
Answer: If you forgot an equal symbol, "7=a" is an error
Page: 261
Chapter: 10
Section: 3.3

Question: Returning a reference to a local variable
Answer: is an error
Page: 262
Chapter: 10
Section: 3

Name: The set of constant expression
Definition: containing literal types
Page: 262-267
Chapter: 10
Section: 4
Context: C++
Definition2: containing enumerator
Conjdef: The smallest S
Definition3: closed under operators returning values
Intuition: An expression that can be computed at compilation time
Definition4: a constexpr variable
Definition5: closed under applying constexpr function
Definition6: a const variable initialized by an element of this set (to be avoided)
Definition7: contain struct with empty body and members initialized with elements of this set
Definition8: Dereferencing, assuming the reference is initialized with an object of this set

Question: Why prefer named constant to literals ?
Answer: It makes the code easier to understand and maintain
Page: 263
Chapter: 10
Section: 4
Context: C++
Answer2: when initialization is done at compile time, there can be no data races in on that object in a multi-threaded environment
Answer3: Sometimes, evaluating something once (at compile time) gives significantly better performance than doing so a million times at run time.

Question: Why prefer named constant to variables ?
Answer: A variable might be changed (so we have to be more careful in our reasoning than for a constant).
Page: 263
Chapter: 10
Section: 4

Question: Why prefer named constant to variables ?
Answer: A variable might be changed (so we have to be more careful in our reasoning than for a constant).
Page: 263
Chapter: 10
Section: 4
Answer2: The language requires constant expressions for array sizes, case labels, and template
value arguments.
Answer3: Embedded systems programmers like to put immutable data into read-only memory
because read-only memory is cheaper than dynamic memory (in terms of cost and energy
consumption), and often more plentiful.
Answer4: data in read-only memory is immune to most system crashes

Typ: constexpr t
Meaning: Indicates that the expression is assigned immediately, and computed at compile time or raison an error if it's not possible
Page: 263
Language: C++
Chapter: 10
Section: 4
Variables: t a variable

Question: How to do conditional in constant expressions ?
Answer: Use the ternary operator
Page: 263
Chapter: 10
Section: 4
Variables: t a variable

Name: A conversion
Definition: Changing a value for a similar value of another type
Page: 267
Chapter: 10
Section: 4
Context: C++

Name: A value-preserving conversion
Definition: A conversion that can be cancelled (i.e. can not loose any information)
Page: 267
Chapter: 10
Section: 4
Context: C++
Example: Long to int
Name2: A promotion
Counterexample: float to int

Name: A narrowing conversion
Definition: A conversion that can not be cancelled (i.e. can loose any information)
Page: 267
Chapter: 10
Section: 4
Context: C++
Example: long long to int
Counterexample: int to double

Question: A value of type t* can be implicitly converted to
Answer: A void* pointer
Page: 267
Chapter: 10
Section: 4
Variables: t an object type
Answer2: p*  with p an unambiguous base type inherited by t
Answer3: const t*

Question: A value of type t*, for t a function type, can be implicitly converted to
Answer: nothing
Page: 267
Chapter: 10
Section: 4

Question: A value of type t&, for t a function type, can be implicitly converted to
Answer: const t&
Page: 267
Chapter: 10
Section: 4

Instruction: int(f)
Page: 267
Language: C++
Chapter: 10
Section: 4
Returns: the integer part of f (floor of f)
Variables: f a floating point expression

Question: Arithmetic operation with one floating point and one integral operand
Answer: Convert integral type to float before applying the operation
Page: 271
Chapter: 10
Section: 5.3

Question: Arithmetic operation with unsigned t and signed t
Answer: Convert signed to unsigned before applying the operation
Page: 271
Chapter: 10
Section: 5.3

Question: Arithmetic operation with a type and a strictly smaller type
Answer: Convert smaller type to bigger one before applying the operation
Page: 271
Chapter: 10
Section: 5.3

Question: Arithmetic operation with a type smaller than int
Answer: Convert number to ints before applying the operations
Page: 271
Chapter: 10
Section: 5.3

Page: 260
Syntactic sugar: expr_1 && expr_2
Implementation: auto value_1 = expr_1;
(!value_1)? value_1 : expr_2;
Language: C++
Section: 3.2
Chapter: 10

Page: 260
Syntactic sugar: expr_1 || expr_2
Implementation: value_1 = expr_1;
(value_1)? value_1 : expr_2;
Language: C++
Section: 3.2
Chapter: 10

Name: The set of constant expression
Page: 262-267
Section: 4
Chapter: 10
Index: C++
Under: operators returning values
Under2: applying function
Condition2: constexpr
Under3: Dereferencing
Condition3: the reference is initialized with an object of this set
Under4: a const variable
Condition4: initialized by an element of this set (to be avoided)
Closure5: constant expression
Closure6: struct
Condition6: empty body and members initialized with elements of this set