do-while, casts, ODR, variadic templates - Core C++, Part 8

do-while, casts, ODR, variadic templates - Core C++, Part 8

Rate This
  • Comments 5

Part 8 of my third video lecture series (covering the C++ Core Language) is now available.  In this part, I covered several topics: why I avoid do-while loops, how C and C++ casts behave and why they're dangerous, what the One Definition Rule is and how to follow it, and how my toy program to sort arrays with variadic templates works.

For reference, here are all of the links to my video lectures, plus my GoingNative 2012 presentation:

 

[STL Introduction]

Part 1 (sequence containers)

Part 2 (associative containers)

Part 3 (smart pointers)

Part 4 (Nurikabe solver) - see Wikipedia's article and my updated source code

Part 5 (Nurikabe solver, continued)

Part 6 (algorithms and functors)

Part 7 (algorithms and functors, continued)

Part 8 (regular expressions)

Part 9 (rvalue references)

Part 10 (type traits)

 

[Advanced STL]

Part 1 (shared_ptr - type erasure)

Part 2 (equal()/copy() - algorithm optimizations)

Part 3 (_ITERATOR_DEBUG_LEVEL, #pragma detect_mismatch, and /d1reportSingleClassLayout)

Part 4 (rvalue references v2.1 and associative container mischief)

Part 5 (deduplicator, using Boost.Bimap, Filesystem, and ScopeExit) - see my deduplicate.cpp

Part 6 (container pretty printer) - see my pretty_printer.cpp

 

[GoingNative 2012]

STL11: Magic && Secrets (make_shared<T>(), emplacement, pair SFINAE, range-based for-loop) - see my slides

 

[Core C++]

Part 1 (name lookup)

Part 2 (template argument deduction)

Part 3 (overload resolution)

Part 4 (virtual functions)

Part 5 (specializations)

Part 6 (variadic templates, raw string literals, explicit conversion operators, default template arguments for function templates, delegating constructors, uniform initialization)

Part 7 (usual arithmetic conversions)

Part 8 (do-while, casts, One Definition Rule, sorting arrays with variadic templates) - see my array_sorter.cpp

 

Stephan T. Lavavej

Senior Developer - Visual C++ Libraries

stl@microsoft.com

  • If I post here but it is thrown away, have I posted?

  • These series of videos are excellent. Thank you for sharing!

  • int main( int argc, const char* argv[] ) // STL, since you ensure bugs get fixed. Compile me with Unix Line Endings.

    {

       return 0;

    }

    #error "oops"

    // crap.cpp(6) : fatal error C1004: unexpected end-of-file found (oops line)

    void f()

    {

    }

  • Cole: I'm glad you like them, thanks for watching!

    Bug Hunter: I've filed DevDiv#625103 "With Unix line endings, #error directives trigger fatal error C1004: unexpected end-of-file found" in our internal database.

  • There is nothing inherently wrong with a do-while loop. Avoid them just because is silly.

Page 1 of 1 (5 items)