DiscoverC9 Lectures: Stephan T. Lavavej - Core C++ (Audio) - Channel 9
C9 Lectures: Stephan T. Lavavej - Core C++ (Audio) - Channel 9
Claim Ownership

C9 Lectures: Stephan T. Lavavej - Core C++ (Audio) - Channel 9

Author: Microsoft

Subscribed: 1Played: 4
Share

Description

Stephan T. Lavavej, aka STL, is back on C9! This time, STL will take us on a journey of discovery within the exciting world of Core C++ (standard C++, the core language). We know lots of folks are either coming back to C++, coming to C++, or have never left C++. This lecture series, in n parts, is for all of you! Only STL can make that work (novice, intermediate, and advanced all bundled together and presented in a way that's appropriate for all).
10 Episodes
Reverse
In part 10, STL explores the new features in the Visual C++ Compiler November 2013 CTP (Community Technology Preview), in addition to the features that were added between VC 2013 Preview and RTM.Features included in the November CTP ( generic lambdas!!! ):C++11, C++14, and C++/CX features:Implicit move special member function generation (thus also completing =default)Reference qualifiers on member functions (a.k.a. "& and && for *this")Thread-safe function local static initialization (a.k.a. "magic statics")Inheriting constructorsalignof/alignas__func__Extended sizeofconstexpr (except for member functions)noexcept (unconditional)C++14 decltype(auto)C++14 auto function return type deductionC++14 generic lambdas (with explicit lambda capture list)(Proposed for C++17) Resumable functions and await See part 1: Name Lookup See part 2: Template Argument Deduction See part 3: Overload Resolution See part 4: Virtual Functions See part 5: Explicit and Partial Specialization See part 6: New C++11 features added to the Visual C++ 2012 compiler (CTP)See part 7: Usual Arithmetic Conversions and Template MetaprogrammingSee part 8: do-while loop, casts, one definition ruleSee part 9: lambdas and other expressions
In part 9, STL digs into lambdas and other expressions. Lambdas are very useful and you've know doubt been enjoying them in your modern C++ programming. As you can imagine, STL will go deep and teach you things about lambdas that you may not know. You'll also learn a lot about order of precedence and associativity for expressions in only the way Stephan can teach you (thorough treatment). Tune in.See part 1: Name Lookup See part 2: Template Argument Deduction See part 3: Overload Resolution See part 4: Virtual Functions See part 5: Explicit and Partial Specialization See part 6: New C++11 features added to the Visual C++ 2012 compiler (CTP)See part 7: Usual Arithmetic Conversions and Template MetaprogrammingSee part 8: do-while loop, casts, one definition rule
In part 8, STL digs into the do-while loop, casts, one definition rule (ODR), and his variadic template array sorter. There is a lot of information in this episode, so get comfortable, tune in, and learn.See part 1: Name Lookup See part 2: Template Argument Deduction See part 3: Overload Resolution See part 4: Virtual Functions See part 5: Explicit and Partial Specialization See part 6: New C++11 features added to the Visual C++ 2012 compiler (CTP)See part 7: Usual Arithmetic Conversions and Template Metaprogramming 
In Part 7, STL teaches us about Usual Arithmetic Conversions, Template Metaprogramming, and shares some of the STL internal implementation ( some of it not yet released ). Many of you have asked for some treatment of TMP and STL delivers! Merry Christmas. Here's hoping you all have a wonderful 2013. See part 1: Name LookupSee part 2: Template Argument DeductionSee part 3: Overload ResolutionSee part 4: Virtual FunctionsSee part 5: Explicit and Partial SpecializationSee part 6: New C++11 features added to the Visual C++ 2012 compiler (CTP)
Part 6 is a special episode in which Stephan takes a look at the latest C++11 features that were just added to the Visual C++ compiler:Variadic templates Raw string literalsExplicit conversion operatorsDefault template arguments for function templatesDelegating constructorsUniform initializationThis compiler is now available as a Customer Technology Preview release to everyone. If you want to test-drive this new compiler too, download it from here: https://aka.ms/vc-ctp. More details on this release are available on Visual C++ Blog (https://blogs.msdn.com/vcblog/).Make sure to watch Herb Sutter's C++ keynote at BUILD 2012.See part 1: Name LookupSee part 2: Template Argument DeductionSee part 3: Overload ResolutionSee part 4: Virtual FunctionsSee part 5: Explicit and Partial Specialization
In Part 5, Stephan teaches us about Explicit and Partial Specialization of class and function templates.From MSDN ->Class templates can be specialized for specific types or values of the template arguments. Specialization allows template code to be customized for a specific argument type or value. Without specialization, the same code is generated for each type used in a template instantiation. In a specialization, when the specific types are used, the definition for the specialization is used instead of the original template definition. A specialization has the same name as the template of which it is a specialization. However, a template specialization can be different in many ways from the original template. For example, it can have different data members and member functions.Use specialization to customize a template for a specific type or value. Use partial specialization when the template has more than one template argument and you only need to specialize one of them, or when you want to specialize behavior for an entire set of types, such as all pointer types, reference types, or array types. // explicit_specialization1.cpp // compile with: /EHsc #include <iostream> using namespace std; // Template class declaration and definition template <class T> class Formatter { T* m_t; public: Formatter(T* t) : m_t(t) { } void print() { cout << *m_t << endl; } }; // Specialization of template class for type char* template<> class Formatter<char*> { char** m_t; public: Formatter(char** t) : m_t(t) { } void print() { cout << "Char value: " << **m_t << endl; } }; int main() { int i = 157; // Use the generic template with int as the argument. Formatter<int>* formatter1 = new Formatter<int>(&i); char str[10] = "string1"; char* str1 = str; // Use the specialized template. Formatter<char*>* formatter2 = new Formatter<char*>(&str1); formatter1->print(); formatter2->print(); } See part 1: Name Lookup See part 2: Template Argument Deduction See part 3: Overload ResolutionSee part 4: Virtual Functions
In part 4, Stephan teaches us about Virtual Functions. In parts 1-3, we learned about compile-time constructs. Now, we enter the realm of runtime. STL spends some time discussing inheritance and a bit about access control.Tune in. Learn.See part 1: Name LookupSee part 2: Template Argument DeductionSee part 3: Overload ResolutionSee part 5: Explicit and Partial Specialization
In Part 3, STL digs into Overload Resolution. A function template can overload non-template functions of the same name. In this scenario, function calls are resolved by first using template argument deduction to instantiate the function template with a unique specialization (STL taught us all about TAD in Part 2). If template argument deduction fails, the other function overloads are considered to resolve the call. These other overloads, also known as the candidate set, include nontemplate functions and other instantiated function templates. If template argument deduction succeeds, then the generated function is compared with the other functions to determine the best match, following the rules for overload resolution. [source]As STL says: "I walk through why foo(const T&) beats foo(const T *), when given int *. The reason is surprisingly subtle."Tune in.
In part 2, STL will teach us all about Template Argument Deduction. Template arguments are deduced when a call is made to a template function, but some or all template arguments are omitted. The compiler will attempt to deduce the intended template arguments. In most cases, this works as expected. If it does not, a compilation error occurs, in which case you should specify the template arguments explicitly. Now, let's see what Stephan has to say about this.Tune in. Learn.See part 1: Name Lookup
In part 1, STL focuses on Name Lookup, which is a surprisingly complex process.Remember Herb Sutter's great GotW post (#30, to be precise) on Name Lookup? Here's the problem from that post, to refresh your memory (Thanks to Herb for providing information like this on GotW!):In the following code, which functions are called? Why? Analyze the implications?namespace A { struct X; struct Y; void f( int ); void g( X ); } namespace B { void f( int i ) { f( i ); // which f()? } void g( A::X x ) { g( x ); // which g()? } void h( A::Y y ) { h( y ); // which h()? } } We recommend you watch this entire episode before playing around with Herb's sample above (and don't read the GotW answer, either! That's cheating. Learn from STL. He's an outstanding teacher, as you know.) Please supply feedback on this thread, especially as it relates to what you'd like STL to focus on in subsequent episodes. For part 2, STL will focus on Template Argument Deduction. Tune in. Enjoy. Learn.
Comments