Commit 27ea7249 authored by Kulkarni, Apurv's avatar Kulkarni, Apurv
Browse files

Update 14_metaprogramming.tex

Line54:either  
Line120: This prevents  
Line207: calls
parent 97aa1d3d
......@@ -51,7 +51,7 @@ We distinguish two types of template metaprogramming
% -------------------------------------------------------------------------------------------------
\subsection{Metafunctions}
Classical function get their inputs as values in the function parameters can return values wither in the return statement or in an output
Classical function get their inputs as values in the function parameters can return values either in the return statement or in an output
function parameter. In contrast, metafunctions get their input as template parameters and provide their results either as typedef (type alias)
or as static constant. Thereby, metafunctions are typically class templates.
......@@ -117,7 +117,7 @@ Or you pass the values as integral constants:
\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
have a type. The prevents from implementing something like loops where you update a counter during iteration. This makes it more
have a type. This 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.
In order to illustrate a recursive algorithm implemented using templates, we consider the factorial computation.
......@@ -204,7 +204,7 @@ and the corresponding assembler code:
\subsubsection{Value aliases}
Instead of accessing the result of a computation in a template metafunction by the \cpp{value} member, it is common standard to
introduce a variable template for this purpose that simplifies the calles and makes it look very similar to regular function calls:
introduce a variable template for this purpose that simplifies the calls and makes it look very similar to regular function calls:
%
\begin{minted}{c++}
template <int N>
......
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