Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ashok Kumar, Bharath
so2021
Commits
27ea7249
Commit
27ea7249
authored
Mar 02, 2020
by
Kulkarni, Apurv
Browse files
Update 14_metaprogramming.tex
Line54:either Line120: This prevents Line207: calls
parent
97aa1d3d
Changes
1
Hide whitespace changes
Inline
Side-by-side
lecture/14_metaprogramming.tex
View file @
27ea7249
...
...
@@ -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
w
ither in the return statement or in an output
Classical function get their inputs as values in the function parameters can return values
e
ither 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. Th
e
prevents from implementing something like loops where you update a counter during iteration. This makes it more
have a type. Th
is
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 call
e
s 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>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment