Lecture #26 - Template Metaprogramming

Web Resources:

CppReference.com, CPlusPlus.com, C++ TechLinks
Going Native 2013 - many experts
Herb Sutter's Blog, Herb Sutter on C++11, Herb Sutter keynote - Going Native 2012
Scott Meyer's Blog, S.M. on thread suspension, S.M.: C++11 Sampler
Stroustrup's Home Page, Code Project, Boost Library

Content:

In this lecture we begin a discussion of template metaprogramming.
  1. Syllabus
    Describes topics to be covered, reading material for you to digest before coming to class, and due dates for the assigned projects.
  2. MTMU Help Sessions:

    • Friday, 4/28 at 10:30am in CST 4-201 (Project #4 help from 9:00am to 10:30am)
    • Friday, 5/5 at 9:00am in CST 4-201
      Note: time and place have changed to 5/5 at 1:00pm, 369 Link Hall
  3. Projects:

    Project #4, Project4HelpS17
    Remote Code Publisher

    Project4HelpS17
    C++\CLI WPF client that sends and gets messages using native C++ mock channel.
    C# WPF client with C++\CLI shim that sends and gets messages using native C++ mock channel.
    Also included are several diagrams that illustrate design ideas for Project #4 and some sample Socket code.

    Communication Channel, vsdx
    Diagrams for Peer-To-Peer communication, Client and Server communication processing, and Message structure

    Mock Channel Demo, vsdx
    Diagram illustrating native C++ to C++\CLI interoperation for the Project #4 GUI via a mock demo.

    Note:
    Project #4 is due Tuesday, May 02. We will charge 1 point per day for Wednesday and Thursday. After Thursday midnight the late fee increases to 5 points per day. Also, after midnight Thursday, we will not count bonus points. This is necessary since we have a very short time to complete grading projects and submit course grades.
  4. Unit Test Framework
  5. Preliminaries:

    Program Scope and global data
    Scope inclusion rules

    Programming Languages, vsdx
    History of imperative, functional, and scripting langugages.
  6. Template Metaprogramming

  7. The D Programming Language:

  8. Open Source Libraries:

  9. C++11 - new features

    Herb Sutter's excellent and brief overview from his Blog

    C++11 concurrency
    Threads, locks, condition variables, async, futures, promises, packaged_tasks, and atomics

    C++11 BlockingQueue
    Uses condition variable and mutex to build a queue that blocks deQers when empty.

    Str strings
    Demonstrates move constructor and move assignment.

    Component Reference Counting
    Demonstrates variadic templates and functions.

    Symbol Table
    Illustrates how using aliases are a great design tool. Also demonstrates range-based for loops.

    Chrono Timer
    Uses Chrono library to build a high resolution timer precise to about 100 nanoseconds.

    Callable Objects
    Demonstrates lambdas and compares them to function pointers and functors.

    Singleton
    Uses atomic.

    Uniform Initialization
    Illustrates use of uniform initialization for user defined types and STL containers.

  10. C++11 - The new standard:

    C++ Reference - includes C++11

    What is C++11?
    A guide to Lambdas
    Local, anonymous function definition
    Move semantics and rvalue references
    Pass by value and return by value doesn't need to make copies
    make_shared
    Don't need delete if you use make_shared smart pointer.
    Type Inference
    Type declaration using auto that adopts the type of an expression result.
    Range-based for loops
    C++11 Thread support
    std::Thread documentation.
    C++ 11 std::async
    Clean semantics for calling a function asynchronously.

  11. Other C++11 References:

  12. C++11 Videos and Blogs:

    Herb Sutter on C++11
    Outstanding presentation on the things you can do better with C++11.

    C++ and Beyond
    Herb Sutter's talk on lambdas
    Herb Sutter's C++ and Beyond 2011 talk
    Herb Sutter's Effective Concurrency series
    Herb Sutter on Concurrency

    Herb Sutter's talk at PDC05 - skip the animations install
    This is an outstanding discussion of new features planned for C++ wrapped in an amazing discussion of concurrency.
    Slides from Herb Sutter's talk at PDC05

  13. Advanced C++ Texts

  14. Common C++ Problems
  15. Fragile Designs
  16. UML Notation Revisited

CST strip