Templates and Metaprogramming

Recently I’ve begun to take over a club called Game Engine Architecture Club at DigiPen. The founder of the club graduated and asked me to try running it. I’ve found it be to a lot of fun! The first lecture I did was on template metaprogramming in C++ (TMP).

The lecture was recorded live and is currently up on DigiPen’s youtube channel for public viewing. Though the slides are visible during the video, I don’t think I can share the slides themselves publicly.

Hope you enjoy the video!


6 thoughts on “Templates and Metaprogramming

  1. MD

    Interesting presentation, thanks for sharing! :-)

    One note — expression templates (ETs) are not outdated, moving (in practice implemented as pointer(s) rebinding) is still more expensive than not moving — and is not applicable for all the use cases of ETs, see “C++11’s Move Semantics Are Not Free”: http://preney.ca/paul/archives/1009

    Move semantics and lambdas don’t completely replace ETs:

    “Technically, you can do still better with expression templates, by delaying evaluation of the whole expression until assignment and adding all the matrices “in parallel,” making only one pass over the result. It would be interesting to know if there is a problem that has a truly optimal solution with rvalue references; one that can’t be improved upon by expression templates. ”
    // http://cpp-next.com/archive/2009/09/making-your-next-move/

    ETs are actually quite useful in gamedev, since they come in handy when implementing linear algebra routines efficiently:

    Eigen is a prime example:

    Another note — type traits with static_assert (and then also std::enable_if, but it’s less preferable) replace many use cases of SFINAE:
    // Boost.TTI is also relevant here: http://www.boost.org/libs/tti/
    That being said, C++11 bring a pretty cool improvement, Expression SFINAE: http://stackoverflow.com/questions/12654067/what-is-expression-sfinae

    1. Randy Gaul Post author

      Oh wow, thanks a lot for all the cool information! Yeah like I mentioned, I haven’t studied ETs much at all, so it makes sense there’s a lot more to be said about them. I’ll be checking out some of your links.

  2. Andrea Bigagli

    Nice talk,

    but are you sure C++11 allows for function template partial specialization?

    I couldn’t have neither clang 3.3 nor gcc 4.8.1 get to compile one and I couldn’t find mention in to the standard.



    1. Randy Gaul Post author

      I’m actually not sure at all. I don’t keep up very closely with upcoming features. I just recall seeing that somewhere as a planned feature.

  3. Pingback: Performance em C++ | Vinipsmaker labs

Leave a Reply

Your email address will not be published. Required fields are marked *