Commit 4e5fbe9f authored by Felix Hilsky's avatar Felix Hilsky
Browse files

change can not to cannot

is correct english, see
https://www.grammarly.com/blog/cannot-or-can-not/
parent f471a381
......@@ -315,7 +315,7 @@ Some remarks to the examples above:
% ==============================================================================
\section{Variable declaration and fundamental types\label{sec:data-type}}
C++ is a statically typed language (in contrast to dynamically typed languages like \eg PHP), meaning: each identifier and expression in a
C++ program has assigned a type that is already known to the compiler and this type can not be changed.
C++ program has assigned a type that is already known to the compiler and this type cannot be changed.
Examples:
\begin{minted}{c++}
......@@ -572,7 +572,7 @@ Example:
\end{minted}
(Fine if \cpp{long} is 64Bit long, wrong value if \cpp{long} is only 32Bit long)
We call an initialization of a value to a smaller type that can not represent this value a \emph{narrowing initialization} or
We call an initialization of a value to a smaller type that cannot represent this value a \emph{narrowing initialization} or
\emph{narrowing conversion}. In the example above, the compiler will not give any error and compiles fine, although the value might be wrong.
Maybe the compiler prints a warning, but not on all warning levels and this is not guaranteed.
......@@ -666,7 +666,7 @@ A \cpp{constexpr} variable must satisfy the following requirements:
\item the full-expression of its initialization, including all implicit conversions, constructors calls, etc, must be a constant expression
\end{itemize}
The category \emph{LiteralType} can not yet be fully explained, but especially the fundamental types discussed above are \emph{LiteralTypes}.
The category \emph{LiteralType} cannot yet be fully explained, but especially the fundamental types discussed above are \emph{LiteralTypes}.
\begin{rem}
\cpp{constexpr} variables, expressions and functions are a powerful tool within C++, available since \cxx{11} and extended in \cxx{14} and \cxx{17}.
......@@ -924,7 +924,7 @@ This structured binding does not only work for tuple-like structures, but also f
\end{minted}
\begin{rem}
Tuples (and pairs) can not be traversed like other containers. The reason is that each element in a tuple has a different type and in a loop the elements must have the same type in each iteration. Currently the standard committee discusses and extended version of a loop, like \cpp{for...(auto t : tuple)} or \cpp{for constexpr(auto t : tuple)}. But this is not yet decided. We will see later in the chaper about meta-programming how to write a loop over tuples yourself. Then you get something like
Tuples (and pairs) cannot be traversed like other containers. The reason is that each element in a tuple has a different type and in a loop the elements must have the same type in each iteration. Currently the standard committee discusses and extended version of a loop, like \cpp{for...(auto t : tuple)} or \cpp{for constexpr(auto t : tuple)}. But this is not yet decided. We will see later in the chaper about meta-programming how to write a loop over tuples yourself. Then you get something like
\begin{minted}{c++}
forEach(tuple, [](auto t) {
std::cout << t << std::endl;
......
......@@ -63,7 +63,7 @@ There are essentially two ways how to pass values/arguments to functions:
int main() {
int j = 4;
foo(j); // j can not be changed by foo
foo(j); // j cannot be changed by foo
return 0;
}
\end{minted}
......@@ -122,7 +122,7 @@ must be set to arguments starting from the last one.
\end{example}
\begin{rem}
One can not directly set a default value for the first argument and no default value for the second argument. If a default is set, for argument $n$, all
One cannot directly set a default value for the first argument and no default value for the second argument. If a default is set, for argument $n$, all
following arguments also must have a default value.
An alternative to these default values, are \emph{optional} values. This is a library extension in \cxx{17}\marginpar{[\cxx{17}]}, where the actual default
......
......@@ -174,17 +174,17 @@ Which one you mean is determined by the position of the \cpp{const} qualifier, \
int data = 42, data2 = 1234;
int const* i1 = &data;
*i1 = 7; // ERROR: can not modify constant data
*i1 = 7; // ERROR: cannot modify constant data
i1 = &data2; // OK: i1 now points to data2
int* const i2 = &data;
*i2 = 7; // OK: data is not const
i2 = &data2; // ERROR: can not change address of const pointer
i2 = &data2; // ERROR: cannot change address of const pointer
int const* const i3 = &data; // completely imutable
\end{minted}
Since one can not have a reference of a reference, one can also not declare a pointer to a reference (something like \cpp{int&*}), but a
Since one cannot have a reference of a reference, one can also not declare a pointer to a reference (something like \cpp{int&*}), but a
pointer is a regular type representing an address, it can be referenced, \ie
%
\begin{minted}{c++}
......
......@@ -78,7 +78,7 @@ Example:
static_assert(SIZE(mat) == 4, "");
\end{minted}
One can not directly determine the rank of a matrix/tensor and thus number of rows and columns of a matrix without prior knowledge of the shape
One cannot directly determine the rank of a matrix/tensor and thus number of rows and columns of a matrix without prior knowledge of the shape
is not possible to detect with macros.
......@@ -202,7 +202,7 @@ may simply overwrite the data stored at the specific memory location $\rightarro
it may lead to undefined behavior (and often produces a runtime-error of the form ``invalid pointer'').
\end{guideline}
Another problem with dynamic arrays is that you can not even see whether it is an allocated array, or just an uninitialized pointer variable. So,
Another problem with dynamic arrays is that you cannot even see whether it is an allocated array, or just an uninitialized pointer variable. So,
here again the general rule applies: initialize variables directly on declaration. If you do not yet have an address to initialize the pointer with,
set it to zero, \ie
%
......@@ -253,7 +253,7 @@ Pointers can be dereferenced, giving a reference to the data it points to. Addit
equivalent to \cpp{*(pointer + n)}.
Requirement for using pointer arithmetic is that the data has a defined size (complete types). The ``empty-set'' type \cpp{void} can be used as a pointer type,
meaning just the address without any reference to the data-type of the stored data. Since \cpp{void} does not have a size, pointers to \cpp{void} can not
meaning just the address without any reference to the data-type of the stored data. Since \cpp{void} does not have a size, pointers to \cpp{void} cannot
be used in pointer arithmetics.
......
......@@ -191,7 +191,7 @@ in that function. If you have a \cpp{const} class object or a \cpp{const&} to a
% -------------------------------------------------------------------------------------------------
\subsection{Static Members}
Static variables (class variables) or static function (class functions) are shared by all instances of that class and are introduced with the keyword \cpp{static}.
Static variables must be defined outside of the class. Since they are independent of any instance. Static members can not be initialized in a constructor.
Static variables must be defined outside of the class. Since they are independent of any instance. Static members cannot be initialized in a constructor.
%
\begin{minted}{c++}
class MyPoint
......@@ -444,7 +444,7 @@ by using the keyword \cpp{= default}, as above:
};
\end{minted}
Also, one could explicitly mark the copy constructor as \emph{deleted} to enforce that a class can not be copied. This can be accomplished by using the
Also, one could explicitly mark the copy constructor as \emph{deleted} to enforce that a class cannot be copied. This can be accomplished by using the
keyword \cpp{= delete}, similar to the default.
\begin{guideline}{Attention}
......@@ -471,7 +471,7 @@ The argument to the assignment operator thereby is the same as for the copy cons
};
\end{minted}
\textbf{Note}: You can not use the initializer-lists anywhere outside of constructors, thus especially not in assignment operators. Therefore, the copy has to
\textbf{Note}: You cannot use the initializer-lists anywhere outside of constructors, thus especially not in assignment operators. Therefore, the copy has to
happen in the function body.
\begin{guideline}{Principle}
......@@ -531,12 +531,12 @@ implicitly declared only of
\item there are no user-declared destructors;
\end{itemize}
and is implicitly deleted if some data members (or base-classes) can not be moved.
and is implicitly deleted if some data members (or base-classes) cannnot be moved.
In case the default behavior would make sense but another constructor or destructor of the list above is defined, one can force the compiler to generate
the move-constructor automatically, using the keyword \cpp{= default}, as above.
Also, one could explicitly mark the move constructor as \emph{deleted} to enforce that a class can not be moved. This can be accomplished by using the
Also, one could explicitly mark the move constructor as \emph{deleted} to enforce that a class cannot be moved. This can be accomplished by using the
keyword \cpp{= delete}, similar to the default.
Similar to the copy constructor, there is a cousin of the move constructor, the move assignment operator: This should be defined whenever a move constructor
......@@ -621,7 +621,7 @@ Additionally, there is the access restriction \cpp{protected} that we will see l
Point p{1.0, 2.0}; // Initialization
p.x; // OK: x is a public member variable
p.a: // ERROR: a ist a private member and can not be accessed from outside the class
p.a: // ERROR: a ist a private member and cannot be accessed from outside the class
p.foo(); // OK: foo is a public member function
p.bar(); // ERROR: bar is a private member function
......@@ -638,7 +638,7 @@ have this access restriction.
\begin{rem}
Also constructors can be restricted. This allows to instantiate a class (or copy/move a class) in a specific way only. If there are no public
constructors available, the class can not be instantiated directly and one has to provide a ``factory''-function instead, \ie a static public
constructors available, the class cannot be instantiated directly and one has to provide a ``factory''-function instead, \ie a static public
member function that constructs and returns the instantiated class.
\end{rem}
......
......@@ -155,7 +155,7 @@ Actually, in C++ first the template parameter deduction was invented and later t
\begin{minted}{c++}
double a = 1.0;
float b = 2.0f;
abs_difference(a,b); // ERROR: can not deduce template parameters
abs_difference(a,b); // ERROR: cannot deduce template parameters
\end{minted}
%
The parameter \texttt{T} could be either deduced to \cpp{double} or to \cpp{float}.
......@@ -265,7 +265,7 @@ where \texttt{TYPES...} is a list of concrete types (without the keyword \texttt
but
%
\begin{minted}{c++}
std::vector v2(7); // ERROR: type can not be deduced. The constructor argument is
std::vector v2(7); // ERROR: type cannot be deduced. The constructor argument is
// just the size of the vector, no value.
\end{minted}
......
......@@ -189,7 +189,7 @@ Without the \emph{capture} clause, it looks like a regular function definition.
\end{example}
The capture list is very similar to a list of constructor argument of the functor. All variables in that list introduce a local
member variable, that can be used inside the lambda expressions function body. Any other variable can not be used there, since it
member variable, that can be used inside the lambda expressions function body. Any other variable cannot be used there, since it
generates an unnamed functor class with an \cpp{operator()} member function that is called on evaluation.
Using the capture list, a connection to the surrounding scope can be established. The following values are possible in the capture list:
......@@ -237,7 +237,7 @@ but, we do not have a name for the type of the parameter like \texttt{S} in the
\end{rem}
Similar to classical templates and the \cpp{auto} placeholder in variable declarations, the function parameters in generic lambdas
can be qualified with \cpp{const}, reference and pointer. But they can not be used as placeholders in other templated types, \eg
can be qualified with \cpp{const}, reference and pointer. But they cannot be used as placeholders in other templated types, \eg
\cpp{std::vector<auto>} is not allowed as function parameter in generic lambdas.
\begin{rem}
......
......@@ -297,7 +297,7 @@ The category is represented by empty classes, forming a hierarchy that represent
\item Directly take the difference between \texttt{first} and \texttt{last} it the iterator is a \emph{Random Access Iterator}
\end{enumerate}
Since the difference is only possible if the type supports this operation, we can not simply use an \cpp{if - else} branching. we have
Since the difference is only possible if the type supports this operation, we cannot simply use an \cpp{if - else} branching. we have
to implement two function, differing only in the iterator category:
%
\newpage
......@@ -504,7 +504,7 @@ constructed from an output-stream object, like \cpp{std::cout}, \cpp{std::cerr}
a delimiter separating the printed elements.
The \cpp{std::ostream_iterator} is a model of a \emph{single-pass} \cpp{OutputIterator}, thus can be ``traversed'' only once. In a second traversal
the state of the output-range is already changed and we can not go back.
the state of the output-range is already changed and we cannot go back.
% -------------------------------------------------------------------------------------------------
......
......@@ -116,7 +116,7 @@ Or you pass the values as integral constants:
\end{minted}
\subsubsection{Recursive programming}
C++ is a statically typed language, meaning: the type of a variable or an alias can not be changed once it is set. And everything must
C++ is a statically typed language, meaning: the type of a variable or an alias cannot be changed once it is set. And everything must
have a type. The prevents from implementing something like loops where you update a counter during iteration. This makes it more
difficult to do programming with templates. Everything has to be implemented using recursion instead of iteration.
......@@ -281,7 +281,7 @@ with assembler output
movl $5, -4(%rbp)
\end{verbatim}
This restriction is removed in \cxx{14} and you can write loops, use if-then-else, introduce local variables and much more. But, you can not do
This restriction is removed in \cxx{14} and you can write loops, use if-then-else, introduce local variables and much more. But, you cannot do
all that is possible with classical functions. Especially, your arguments and return types must be \emph{LiteralType}s like scalar types or
trivial classes.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment