Title: Theory / Unimportant / CS / Programming / C++ / Manual / Norm / 07 Array;
Tags: seen_description hasNotNewEffectReturnsMeaning FromInstruction computer_to_instruction syntactical_sugar type

Typ: t[n]
Meaning: arrays with n elements of type t
Page: 173, 888
Language: C++
Chapter: 7, 31
Section: 3, 2
Variables: t a type
n an integral constant

Name: C-style string
Definition: An array of char ended by a 0
Page: 173
Chapter: 7
Section: 3
Context: C++ standard

Instruction: {bar_1, ..., bar_n}
Page: 175
Language: C++
Chapter: 7
Section: 3
Returns: An array with n elements whose i-th element is bar_i

Question: What happens if you define an array by giving it more element than the size of the array
Answer: it's an error
Page: 175
Chapter: 7
Section: 3.1
Context: C++ standard

Question: What happens if you define an array by giving it less element than the size of the array
Answer: the elements without values are initialized at 0
Page: 175
Chapter: 7
Section: 3.1
Context: C++ standard

Question: Advantage of std::array over built-in array
Answer: is really an object, for example it has assigment
Page: 209
Chapter: 8
Section: 2.2
Context: C++ standard
Answer2: an std::array<foo> is not the same thing as a pointer to an element of type foo

Question: Advantage of built-in array over std::array
Answer: the number of the element can be deduced from the length of the initializer
Page: 209
Chapter: 8
Section: 2.2
Context: C++ standard
Answer2: Quicker ?

Question: Which are the declarations whose "value" are permanent ?
Answer: types
Page: 153
Chapter: 6
Section: 3
Context: C++
Answer2: templates
Answer3: functions
Answer4: constants
Example: aliases

Question: How to assign an array to a variable
Answer: At initialization only. Can't be copied
Page: 175
Section: 3.1

Question: How to create a mutable String
Answer: Assign the string to an array of char
Page: 175
Section: 3.2
Context: C++

Instruction: R"foo(bar)foo"
Page: 178
Language: C++
Chapter: 7
Section: 3.2
Returns: The string "bar", exactly as it is written.
Assuming: bar does not contain the string ")foo"

Instruction: TR"foo(bar)foo"
Page: 178
Language: C++
Chapter: 7
Section: 3.2
Returns: The string of wide character "bar", exactly as it is written.
Variables: T being a type of characetr, L, u, U, u8
Assuming: bar does not contain the string ")foo"

Instruction: L"bar"
Page: 178
Language: C++
Chapter: 7
Section: 3.2
Returns: The string of wide character "bar"
Typ: const wchar_t[]

Instruction: u8"bar"
Page: 178
Language: C++
Chapter: 7
Section: 3.2
Returns: The string of wide character "bar", encoded in utf-8

Instruction: u"bar"
Page: 178
Language: C++
Chapter: 7
Section: 3.2
Returns: The string of wide character "bar", encoded in utf-16

Instruction: U"bar"
Page: 178
Language: C++
Chapter: 7
Section: 3.2
Returns: The string of wide character "bar", encoded in utf-32

Instruction: p+j
Page: 180
Language: C++
Chapter: 7
Section: 4
Returns: A pointer to the i+j-th element of the array
Variables: p a pointer to the i-th element of an array
j an integer
Assuming: \(0\le i+j\le \texttt{array's size}\)

Instruction: (t*) a;
Page: 180
Language: C++
Chapter: 7
Section: 4
Returns: A pointer to the first element of the array a
Variables: t a typet[] a; an array

Instruction: v_1-v_2
Page: 180
Language: C++
Context: Array
Chapter: 7
Section: 4.1
Returns: Equivalent to n_1-n_2, with n_i the position of a_i in an array
Variables: t a typet* v_1 v_2;
Assuming: v_1 and v_2 both points to element of the same array

Instruction: v_1+v_2
Page: 180
Effect: Error
Language: C++
Chapter: 7
Section: 4.1
Variables: t a typet* v_1 v_2;

Instruction: for (t elt : ar) {
  bar
}
Page: 180
Effect: Similar to
for (int i = 0; i < ar.length; i++) {
  elt = ar[i];
  bar;
}
assuming i does not appear in bar
Language: C++
Chapter: 7
Section: 4.1
Variables: t a typet[] ar;
Assuming: ar's size is known at compilation

Instruction: ar[n_1]...[n_dim]
Page: 183
Language: C++
Chapter: 7
Section: 4.2
Returns: The n_dim's element of the n_dim-1's array of ... of the n_1's array of ar
i.e. element of ar at position
\(\sum_{i=1}^{\texttt{dim}}n_i\prod_{j=1}^{i-1}\texttt{size}_j\)
Variables: t a typet[]...[] ar; of dimension dim
Assuming: ar's sizes is known at compilation, except maybe the first

Question: How is encoded a multi-dimensional array t foo[n_1]...[n_dim]
Answer: by a single array of size \(\prod_{i=1}^{\mathtt{dim}}n_i\)
Page: 183
Chapter: 7
Section: 4.2

Question: What occurs when an array is passed as a function argument
Answer: A pointer to the head of the array is passed, the same array is used in caller and callee
Page: 184
Chapter: 7
Section: 4.3