Within C++ is another language, one which is purely functional. Template metaprogramming (TMP) is a skill that evaluates the programmers who know it above those who don't. Troy introduces TMP in this lesson.
- [Narrator] Template Metaprogramming or TMP…is a form of C++ programming.…TMP is a Turing complete, functional programming language…built-in to C++.…TMP variables are always immutable.…TMP doesn't have loops, so we must use recursion.…TMP doesn't have branching, so we use specialization.…Let's explore template metaprogramming…with a couple of code examples.…We have our include files,…which are just iostream and vector…and we're using the namespace std.…So, let's first create an example function,…which demonstrates how to do the same thing…using generic programming.…
So, we're going to say template, which is a keyword here.…And we're going to say type name T.…Then, we're going to use our type…and we're going to say our generic type…and we're going to say T as the return results.…We're going to do a cube function,…which is just going to multiply the past value by three.…And we're going to say const T reference value.…
Value is a primer we're passing in.…And we're going to say return…value times value times value.…
Author
Released
12/11/2018- Unit testing and functional programming
- Binding
- Function and Lambda functions
- C++ templates
- Working with the Standard Template Library and Boost.Hana
- Functional reactive programming
Skill Level Intermediate
Duration
Views
Related Courses
-
Learning Functional Programming with Swift
with Shaun Wassell53m 12s Intermediate -
Learning C++
with Erin Colvin2h 26m Beginner -
C++ Essential Training (2018)
with Bill Weinman5h 32m Intermediate -
C++: Advanced Topics
with Bill Weinman3h 15m Advanced
-
Introduction
-
1. Overview
-
2. Functional Programming in Modern C++
-
Enabling C++ 174m 24s
-
transform instead of map5m 30s
-
copy_if instead of filter2m 59s
-
accumulate instead of reduce2m 51s
-
bind4m 56s
-
Functions6m 54s
-
Lambda functions: Curry3m 38s
-
Lambda functions: Closures2m 20s
-
-
3. Template Metaprogramming
-
C++ templates4m 36s
-
Factorial5m 23s
-
Boost.Hana5m 31s
-
-
4. Functional Reactive Programming
-
RxCpp library5m 21s
-
Conclusion
-
Next steps41s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: C++ templates