--------------------------------------------------------------------------------------------------
It is often wise to check that a pointer argument that is supposed to point to something, actually
points to something:
int count_x(char∗ p, char x)
// count the number of occurrences of x in p[]
// p is assumed to point to a zero-ter minated array of char (or to nothing)
{
if (p==nullptr) return 0;
int count = 0;
for (; ∗p!=0; ++p)
if (∗p==x)
++count;
return count;
}
Note how we can move a pointer to point to the next element of an array using ++ and that we can
leave out the initializer in a for-statement if we don’t need it.
The definition of count_x() assumes that the char∗ is a C-style string, that is, that the pointer
points to a zero-terminated array of char.
In older code, 0 or NULL is typically used instead of nullptr (§7.2.2). However, using nullptr
eliminates potential confusion between integers (such as 0 or NULL) and pointers (such as nullptr).

--------------------------------------------------------------------------------------------------
void f(Vector v, Vector& rv, Vector∗ pv)
{
int i1 = v.sz; // access through name
int i2 = rv.sz; // access through reference
int i4 = pv−>sz; // access through pointer
}

--------------------------------------------------------------------------------------------------
class complex {
double re, im; // representation: two doubles
public:
complex(double r, double i) :re{r}, im{i} {}
............

complex a {2.3}; // construct {2.3,0.0} from 2.3

--------------------------------------------------------------------------------------------------
Vector::Vector(std::initializ er_list<double> lst) // initialize with a list
:elem{new double[lst.siz e()]}, sz{lst.siz e()}
{
copy(lst.begin(),lst.end(),elem); // copy from lst into elem
}
--------------------------------------------------------------------------------------------------

class Container {
public:
virtual double& operator[](int) = 0; // pure virtual function - MUST be implemnted
virtual int size() const = 0; // const member function (§3.2.1.1)
virtual ˜Container() {} // destructor (§3.2.1.2)
};

-------------------------------- move konstruktor -------------------------------------------------
the result out of a function: we wanted to move a Vector rather than to copy it. Fortunately, we can
state that intent:
class Vector {
// ...
Vector(const Vector& a); // copy constr uctor
Vector& operator=(const Vector& a); // copy assignment
Vector(Vector&& a); // move constr uctor
Vector& operator=(Vector&& a); // move assignment
};
Given that definition, the compiler will choose the move constructor to implement the transfer of
the return value out of the function. This means that r=x+y+z will involve no copying of Vectors.
Instead, Vectors are just moved.
As is typical, Vector’s move constructor is trivial to define:
Vector::Vector(Vector&& a)
:elem{a.elem}, // "grab the elements" from a
sz{a.sz}
{
a.elem = nullptr; // now a has no elements
a.sz = 0;
}
The && means ‘‘rvalue reference’’ and is a reference to which we can bind an rvalue (§6.4.1). The
word ‘‘rvalue’’ is intended to complement ‘‘lvalue,’’ which roughly means ‘‘something that can
appear on the left-hand side of an assignment.’’ So an rvalue is – to a first approximation – a value
that you can’t assign to, such as an integer returned by a function call, and an rvalue reference is a
reference to something that nobody else can assign to. The res local variable in operator+() for Vectors is an example.
A move constructor does not take a const argument: after all, a move constructor is supposed to
remove the value from its argument. A move assignment is defined similarly.
A move operation is applied when an rvalue reference is used as an initializer or as the righthand side of an assignment.

schema:
  - http://127.0.0.1:24100/hasura/v1/graphql:
      headers:
        x-hasura-admin-secret: loutak
documents: 'src/**/*.graphql'
generates:
  ./src/types-graphql.d.ts:
    plugins:
      - typescript
      - typescript-operations


PUBLIC_URL="https://sprava.app.elzel.cz/"
GENERATE_SOURCEMAP=true
REACT_APP_TITLE="Správa projektů"
REACT_APP_HASURA_URL="http://127.0.0.1:40010/v1/graphql"
REACT_APP_PUBLIC_URL="https://sprava.app.elzel.cz/"
REACT_APP_VERSION=$npm_package_version
REACT_APP_NAME=$npm_package_name
DISABLE_ESLINT_PLUGIN=true
