C++11 Class

The course attempts to present in details most of the features of the present programming language C++, formerly known as C++0x. The 25th of March 2011 it was approved the final technical draft and the official ISO standard for the C++11 language is available for purchase since the last october. The final publicly available draft is the N3242 and can be obtained at the following link: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf.

The class will be held at the Department of Information Engineering, in Pisa, starting from the summer 2011. The course calendar is available here: Calendar


C++11 course programme:


Core language [part 1]

The lectures will be covering the following topics:

Lesson 1
  • Introduction: from C to C++11 
  • Compilers, translation units and headers 
  • Pre-processing, compiling and linking 
  • Macros 
  • Multi-paradigm: procedural programming 
  • C++ types, overview 
  • Keywords: enum, typedef, static and extern
  • Memory allocation: pointers and memory leaks
Lesson 2
  • Namespace, nested namespace, unnamed namespace 
  • Declarative regions and scopes 
  • Qualified and unqualified names 
  • Using declaration vs. using directive
  • Cv qualifiers: const and volatile 
  • R-value vs. r-value 
  • Reference: r-value reference vs. r-value reference
Lesson 3

  • ODT: one definition rule 

  • Struct 

  • Functions

  • Argument passing: by copy, by l-value reference (const and non-cost), by r-value reference

  • Overloading and signature definition 

Lesson 4

  • Multi-paradigm: OOP
  • Class member functions (part 1)
    • constructors
    • default constructor
    • converting constructor
    • copy constructor
    • assignment operator
  • Simple non-copyable class: deleted method
  • Syntax matters: what you get is not always what you mean
Lesson 5

  • Class member functions (part 2)
    • destructor
    • move constructor
    • move assignment operator
  • CV qualifiers, mutable members, references and pointers
  • Unary operators
    • (explicit) converting operators: operator bool, operator int...
    • operator++, operator-- 
  • Binary operators
    • operator+=, operator-=
    • operator+, operator-, ...
    • comparison: operator==, operator !=, operator<, etc...
  • Dynamic storage: global operator new/delete
  • Mutator and Accessor
Lesson 6
  • Live coding session: my::string class [part 1]
  • Requirements for comprehension:
    • basic understanding of dynamic memory allocations: malloc - free, as well as new - delete
    • basic skill of C-string manipulations:
      • strlen
      • strcmp
      • strcpy 
      • strcat
Lesson 7
  • Live coding session: my::string class [part 2]
  • The following member functions/free functions will be implemented:
    • append
    • operator+=
    • operator+
    • compare
    • operator<
Lesson 8
  • Friend-ness
    • friend function
    • friend class
  • Static members
    • static data member
    • static member function
  • Nested class
  • Nested type names
  • Functor vs. pointer to functions
    • Callable types
  • Local class
Lesson 9-10
  • Inheritance: derived classes
    • slicing, upcasting, downcasting, overriding
  • Constructor, destructors and member functions
  • Copy constructor, assignment operator
  • Move constructor, move assignment operator
  • Polymorphism
    • virtual functions
  • Pure virtual functions and Abstract Base Class
  • Considerations on composition inheritance and software coupling
Lesson 11
  • Function template
    • Function template instantiation and argument deduction
    • Function template vs. macro
  • Class template
    • default template argument
  • Template parameters:
    • type template parameter
    • non-type template parameter
    • template template parameter
  • Typename keyword and dependent names
  • Zero initialization
  • Class and function template example.
Lesson 12
  • Specialization of class template 
  • Partial specialization of class template 
  • Specialization of function template
  • Overloading template functions
    • Partial specialization emulation for function template
  • Template, callable types and high-order functions
    • The Haskell functions map, fodl and foldr... 

Lesson 13

  • Argument passing to template functions by value
  • Argument passing to template functions by l-value reference
  • Argument passing to template functions by r-value reference
  • perfect forwarding and std::forward<> 
  • Type inference
    • auto and decltype() specifier 
Lesson 14
  • Questions and Answers
Lesson 15
  • Introduction to template meta-programming
    • identity
    • numeric meta-functions 
    • factorial and fibonacci 
    • the bin meta-function
  • Variadic Template
    • variadic class
    • variadic meta-function
    • variadic function and perfect forwarding 
Lesson 16
  • Exceptions:
    • how to report an error condition? 
    • throw and catch
    • standard exception classes
      • catching standard exceptions 
    • uncaught exceptions
    • exception specification:
      • noexcept, throw(...)
    • additional C++11 exception handling
      • exception_ptr 
Lesson 17
  • Lambda functions
  • Syntax of lambda
    • capture, parameters, return type and body
  • Examples
  • Lambda vs. functor
  • Notes about the type of lambda expressions
    • toward type-erasure mechanism
Lesson 18
  • POD types
  • Uniform initialization
  • The initializer_list<> class
  • std::begin, std::end
  • for-range loops

Standard library [part 2] 



Multi-threading [part 3]
....


List of recommended books
  • Thinking in C++ vol. 1 and 2 (Eckel)
  • Accelerated C++: Practical Programming by Example (Koenig)
  • Effective C++ (Meyers)
  • More Effective C++ (Meyers)
  • Exceptional C++ (Sutter)
  • More Exceptional C++ (Sutter)
  • Exceptional C++ Style (Sutter)
  • C++ Templates (Vandevoorde - Josuttis)
  • The C++ Standard Library (Josuttis)
  • C++ Standard Library Extensions (Becker)
  • Effective STL (Meyers)
  • Modern C++ Design (Alexandrescu)
  • C++ Coding Standards (Sutter - Alexandrescu)
  • C++ Template Metaprogramming (Abrahams - Gurtovoy)
  • C++ Concurrency in action (Williams)

Comments