SlideShare a Scribd company logo
Philipp Aumayr
                                software architects gmbh



                           Web http://www.timecockpit.com
                           Mail philipp@timecockpit.com
Visual C++ 2012          Twitter @paumayr


Improvements over 2008
                                 Saves the day.
Intro
 DI   Philipp Aumayr
 Senior   Developer @ software architects (time cockpit)
 9-5   -> C#, 5->9 C++, 24/7 VS 2012
 Twitter:   @paumayr
 Blog:   http://www.timecockpit.com/devblog/
Motivation
 Visual   Studio 2012 improvements over 2008
 New Shell
 New Editor
 Better Intellisense
 Unit Testing
 Code Coverage
 Code Analysis
 #include completion
 Navigate To
 Type visualizers
Motivation
 C++11
 New standard released August 12, 2011
 Major overhaul
    Bjarne Stroustrup: „C++11 feels like a new language“
 Visual Studio 2012 has partial support
    Is updated out-of-band (November CTP adds major language parts)

 auto, decltype, range-based for loop
 lambdas, explicit overrides, static_assert
 nullptr, enum classes, move-semantics, variadic templates,
 initializer_lists, delegating constructors,
 explicit conversion operators
Motivation
   STL improvements
    shared_ptr, unique_ptr
    unordered_set, unordered_map
    SCARY iterators + container sizes

   Move Semantics

   std::async

   Code Analysis

   SDL
Motivation
   Auto-vectorization

   Auto-parallelization

   C++ AMP




     A lot to learn, but well worth the effort!
IDE Improvements
   Multi-monitor support
    Rewritten in WPF and MEF

   Improved responsiveness
    Intellisense works in the background
    Asynchronous project loading

   Editor Zooming
   Navigate-To
   Call Hierarchy
   Demo
IDE Improvements
   Preview tab
   Pinned editor windows
   Ctrl + Q / Search Menu
   New Solution explorer
    Scope to this
    multiple views

   Find within editor
   Find all references
   Demo
Test Framework
 Supports     writing unit tests for MSTest
 Test adapters for other test frameworks are available
 Gtest
 xUnit++

 Test   Explorer Window
 Grouping

 Code    Coverage
 Demo
Better Intellisense
 Uses   an SDF (SQL CE database) instead of the ncb
 Faster

 More   robust
 Demo
Type Visualizers (Natvis)
 Allow      customizable data representation in debugger
    Replaces autoexp.dat
    Easier to handle, more powerful

 Create       a natvis file
    Place in either
       %VSINSTALLDIR%Common7PackagesDebuggerVisualizers (requires admin access)
       %USERPROFILE%My DocumentsVisual Studio 2012Visualizers
       Or VS extension folders

   Files are reloaded at every debugging session
    No restart required when changing natvis files
Type Visualizers (Natvis)
 Example      natvis file




 Allows
 conditional strings, node expansions, item lists, tree items, synthetic items, etc.
Break
New Editor
Better Intellisense
Unit Testing
Code Coverage
Code Analysis
#include completion
Navigate To
Type visualizers
Break
 Questions?
C++ Styles (Question)
C   with a C++ compiler?
C   with classes / inheritance?
 RAII,   Exceptions, Smart pointer?
 STL?

 TMP?
auto
 Automatically       deduces type information
 Very similar to „var‟ in c#
 Reduces amount of typing required

 Reference      or Value?
 Value by default, add & to make it a reference

 Demo
decltype
 Represents       the type of the expression
 decltype(2*3) -> int
 decltype(a) -> type of a

 Why?
 Let types flow!

 Demo
Range based for loop
 New   type of for loop
 Iterates   all members of a collection
 Demo
Lambdas
 Anonymous        Functions
 Allows   logic to be placed where required
 Can   capture environment
 General    syntax:
 [capture](parameters)->return-type{body}

 represent    by type std::function<>
Lambdas
 Finally   make STL algorithms useable
 Reduces      amount of (boilerplate-)code
  No more functor classes!
Lambda Captures
 A Lambda        can capture environment
 Allows the lambda to access and modify state

 Capture      kinds
 -   reference or value
 -   automatic or specific

 Demo
override and final
   Explicitly defines overrides
    Compiler helps if no method to override is found

   Helps with refactoring
    Rename method in base class but not in derived -> derived method no longer overrides
    Base class from third party!

   Helps class design
    Implementers of derived classes can more easily understand which methods to override

   final can be used on classes to prevent being derived from

   Demo
override and final
static_assert
 Tests   a software assertion at compile time
 Especially     useful for portable code
 Assert size of specific structures (x86, x64 issues)

 Check    library versions
 Used    to be accomplished using the preprocessor
 Demo
nullptr
0   / NULL used to indicate a null pointer
 nullptr   is of type nullptr_t
 implicitly   assignable to any pointer
 not   assignable to int etc.
enum classes
 C++03    enums
 Not type safe
 Enums of different types can be compared (basically integers)
 Storage type int

 C++11    enum classes
 Type is compared as well!
 Underlying type can be chosen
enum classes
 C++03   enums
enum classes
 C++11   enum classes
Initializer lists (CTP)
Initializer lists (CTP)
 Eases   construction of non-POD types
 Finalversion will provide initialize list constructors for
  STL types
 Binds   {…} syntax to the std::initializer_list<T> type.
 Current   STL does not support it
 Demo                                  name == “class std::initializer_list<int>”
variadic templates (CTP)
 Flexible   number of template arguments
 Usable    for template writers
  n-ary structures (tuples)
  e.g. make_shared, make_tuple
  Example: saveprint

 Beware     of dragons ;)
 Demo
Move Semantics
 C++03:     many (temporary) class instances
 Resulted in a lot of copying
 Constructs to work around
 Passing complex data structure from function

 C++11:     Move semantics
 If the copied value is an rvalue reference, the move constructor is called
Move Semantics
 Dramatically   changes style!
C++03                             C++11
Move Semantics
 Note:   right-hand version is valid C++03 code!
  But advanced programmers avoided it, due to the extra copy involved.

 Now    with C++11: Elegant AND Fast
  Reconsider the patterns you are used to

 All   STL containers implement move semantics
  Returning container was unavoidable? -> automatic performance improvement!

 STL    code will have fewer temporary objects
 Demo
Break
 C++11
 auto, decltype, range-based for loop
 lambdas, explicit overrides, static_assert
 nullptr, variadic templates,
 initializer_lists, enum classes,
 move-semantics
std::async
 C++    11 has built-in support for asynchrony
 available through <future> header

 std::async<T>(std::function)                returns a future<T>
 -   Different launch policies (synchronous, asynchronous)
 -   can be waited on using wait() or get() to retrieve the result

 Implemented          in VC++ using PPL (parallel patterns
 library)
 -   Highly scalable and performant
std::async
 Not
    every asynchronous operation is a thread / cpu
 bound
 Notably IO requests
 User Input etc.

 std::future<T>       can be created from a std::promise<T>!
 std::promise<T>        acts as a provider for a future
 Marshalls result between threads of execution
 correct locking / etc.
 Provides set_value / set_exception
std::async
               T1              T2




                    (Blocks)




Demo
Parallel Patterns Library
 Based     on ConcRT
 Compatible       to Intel Thread Building Blocks (TBB)
 At least interface wise

 Template      Library for parallel programming
 Abstracts concurrent workflows into tasks
 Provides continuations (improvement over std::future<T>)

 Demo
Auto Vectorization
 Modern      CPUs support SIMD
 Single Instruction Multiple Data
 Extensions such as SSE and AVX
 Usually optimized for specifically using compiler intrinsics or inline assembler

                                 Serial                            Vector
                                   x = x1 + x2                  xyzw = xyzw1 + xyzw2


                                   y = y1 + y2


                                   z = z1 + z2


                                  w = w1 + w2
                            τ
Auto Vectorization
 VC++    2012 compiler has an auto-vectorizer (-Qvec)
 Tries to automatically vectorize loops and operators
 Enabled by default
 Diagnosis output using /Qvec-report:2

 Performance        difference?
 Depends.
 Max 4x for SSE (128bit), 8x for AVX (256bit),
 3x-4x typical

 Demo     (later with auto parallelization)
Auto-Parallelization
 To   utilize multiple cores, parallelization is used (MIMD)
 Multiple-Instructions-Multiple-Data

 VC++2012         has an auto-parallelizer
 Can be hinted
    #pragma loop(hint_parallel(N))
    #pragma loop(ivdep)
 Enabled using /Qpar
 Diagnosis using /Qpar-report:2

 Demo
C++ AMP
   Open specification created by Microsoft

   C++ for GPGPU
    Massively Parallel / Vector programming
    Based on top of DirectCompute (windows)
    Clang / LLVM implementation using OpenCL is available
       Provided by Intel (“Shevlin Park”)


   One new keyword
    Restricts the decorated function to a specific subset of c++

   Template library for wrapping data structures
    Datatransfer to/from GPU etc.
Why C++ AMP?
   Directly available from the compiler
    No additional SDK required
    Can reuse types (vector2f e.g.)

   Better debugging experience
    compared to CUDA / OpenCL!

   Makes C++ applicable to heterogeneous computing
    A processor may consist of multiple cores of different flavor
    More energy efficient (mobile!)
    visual computing
       image morphing
       Augmented reality etc.


   Demo
Smaller container sizes
   X86       release, sizes in bytes
Container                 VC9 SP1 / SCL = 0   VC10 (2010)   VC11 (2012)
                          (2008)
vector<int>               16                  16            12
deque<int>                32                  24            20
forward_list<int>         N/A                 8             4
queue<int>                32                  24            20
stack<int>                32                  24            20
unordered_map<int, int>   44                  44            32
string                    28                  28            24
wstring                   28                  28            24 ~14% less!
Smaller container sizes
   x64       release, sizes in bytes
Container                 VC9 SP1 / SCL = 0   VC10 (2010)   VC11 (2012)
                          (2008)
vector<int>               32                  32            24
deque<int>                64                  48            40
forward_list<int>         N/A                 16            8
queue<int>                64                  48            40
stack<int>                64                  48            40
unordered_map<int, int>   88                  88            64
string                    40                  40            32
wstring                   40                  40            32 ~20% less!
Code Analysis
   Static analysis

   Provides warnings at compile time

   Additionally to /GS and /SDL

   Detailed information on warning
Code Analysis
   What does it check ?
    Uninitialized Reads
    HRESULT verification checks
    Concurrency Warnings
    Format string checks
    Correct destructor calls (delete[] vs delete)
    Redundant code checks
    Many more: http://msdn.microsoft.com/en-us/library/a5b9aa09.aspx



   Custom code can be annotated to aid code analysis
    See http://msdn.microsoft.com/en-us/library/ms182032.aspx


   Demo
Break
 std::async

 ppl

 auto   vectorization
 auto   parallelization
 container   sizes
 code   analysis
Custom Snippets
 .snippet   is supported, same as C#
 XML file describing a code snippet
 Declare variables and use them in the snippet body

 Very   helpful for similar but not equivalent code
 Demo
Debug View
 Pin   watch to source code
 Add comments
 Not only variables, but (most) expressions




 View   values from last debug session
 Export   / Import Data Tips
 Makes it easier for debugging with multiple developers / on different machines

 Demo
Parallel Stacks Window
 New   view for debugging
 Better   understanding of multi thread applications
Parallel Tasks Window
 Lists   the task queues
Parallel Watch Window
 Watch     expressions in parallel
 Especially useful in tight loops
 Data races                           Expressions
 Can freeze / thaw threads
 Manually verify locking

 Demo
 Parallel Stacks
 Parallel Tasks
                            Threads
 Parallel Watch
Shortcuts
Shortcut              Action                    Shortcut

Strg + ,              Navigate To               Strg + Q      Search Menu

F12                   Go To Definition          Strg + K, C   Comment lines

Umschalt + F12        Find all references       Strg + K, U   Uncomment lines

Strg + -              Navigate Backwards        Strg + M, O   Collapse To definition

Strg + Umschalt + -   Navigate Forwards         Strg +M, X    Expand All Outlining

Strg + F              Find in current file      Strg +M, S    Collapse Current Region

Strg + H              Replace in current file   Strg + M, E   Expand Current Region
Break
   Custom snippets

   Debug view experience

   Parallel Stacks

   Parallel Tasks

   Parallel Watch Window

   code analysis

   Shortcuts
What‟s next?
 It‟s   a good century for C++ / native developers
  Single thread performance isn‟t getting much better
  memory latency / bandwidth is the bottleneck
  Efficiency is becoming more important (mobile!)

 There     is a huge commitment towards C++
  Google, Apple started a new compiler project a few years ago (Clang / LLVM)
  ISO standard is evolving more quickly
  C++ Standards Foundation (www.isocpp.org)
    Google, Apple, Intel, Microsoft, ARM, IBM, HP, etc.
Upcoming Standards
   Library in std:: for file system handling
    based on boost.filesystem v3
                                                We are here!
   Net TS
    Networking
    HTTP etc.

   TM TS
    Transactional Memory
Wrap-Up
 Tour   around the new IDE        New    Library Features
 Shell / Window handling           std::async
 Solution Explorer                 PPL
 Code Navigation                   Improved container sizes
 Better Intellisense
 Snippets, Debug Experience
 Parallel Watch, Threads, Tasks

                                   New    Compiler Features
 New    Language Features         Code Analysis
 auto, decltype, lambdas,
                                   /SDL /GS
 override, final
                                   Auto Vectorization
 static_assert, nullptr
                                   Auto parallelization
                                   C++ AMP
Philipp Aumayr
                                software architects gmbh




Q&A                        Mail philipp@timecockpit.com
                           Web http://www.timecockpit.com
                         Twitter @paumayr


Thank your for coming!
                                 Saves the day.

More Related Content

PPTX
Objective-c for Java Developers
PDF
Micro-Benchmarking Considered Harmful
PDF
Open mp directives
PDF
Part II: LLVM Intermediate Representation
PDF
Learn C# Programming Polymorphism & Operator Overloading
PDF
Java SE 8 library design
PDF
Use of an Oscilloscope - maXbox Starter33
PPT
ParaSail
Objective-c for Java Developers
Micro-Benchmarking Considered Harmful
Open mp directives
Part II: LLVM Intermediate Representation
Learn C# Programming Polymorphism & Operator Overloading
Java SE 8 library design
Use of an Oscilloscope - maXbox Starter33
ParaSail

What's hot (19)

PDF
Metrics ekon 14_2_kleiner
PPTX
Presentation on Shared Memory Parallel Programming
PDF
Владимир Иванов. Java 8 и JVM: что нового в HotSpot
PDF
Syntutic
PDF
camel-scala.pdf
PPT
Java findamentals1
PPT
Java findamentals1
PPT
Java findamentals1
PDF
Extending and scripting PDT
PDF
EKON 25 Python4Delphi_mX4
PPTX
GCC RTL and Machine Description
PPT
Introduction to llvm
PDF
Introduction to OpenMP
PPTX
The Dark Side Of Lambda Expressions in Java 8
PDF
Ekon 25 Python4Delphi_MX475
PDF
Smart Migration to JDK 8
PDF
Testing Apache Modules with Python and Ctypes
PPTX
PDF
02 c++g3 d
Metrics ekon 14_2_kleiner
Presentation on Shared Memory Parallel Programming
Владимир Иванов. Java 8 и JVM: что нового в HotSpot
Syntutic
camel-scala.pdf
Java findamentals1
Java findamentals1
Java findamentals1
Extending and scripting PDT
EKON 25 Python4Delphi_mX4
GCC RTL and Machine Description
Introduction to llvm
Introduction to OpenMP
The Dark Side Of Lambda Expressions in Java 8
Ekon 25 Python4Delphi_MX475
Smart Migration to JDK 8
Testing Apache Modules with Python and Ctypes
02 c++g3 d
Ad

Viewers also liked (14)

PPTX
WPF and Prism 4.1 Workshop at BASTA Austria
PPTX
Agile and Scrum Workshop
PPTX
Coding Like the Wind - Tips and Tricks for the Microsoft Visual Studio 2012 C...
PPTX
SaaS, Multi-Tenancy and Cloud Computing
PPTX
P/Invoke - Interoperability of C++ and C#
PPTX
The CoFX Data Model
PPTX
Parallel and Async Programming With C#
PPTX
Business Model Evolution - Why The Journey To SaaS Makes Sense
PPTX
Programming With WinRT And Windows8
PPT
Michael Kiener Associates Ltd
PPT
Vertaalbureau Perfect
PPTX
Telerik Kendo UI vs. AngularJS
PPS
Sculptura in coaja de ou
PPTX
Cloud computing was bringt's
WPF and Prism 4.1 Workshop at BASTA Austria
Agile and Scrum Workshop
Coding Like the Wind - Tips and Tricks for the Microsoft Visual Studio 2012 C...
SaaS, Multi-Tenancy and Cloud Computing
P/Invoke - Interoperability of C++ and C#
The CoFX Data Model
Parallel and Async Programming With C#
Business Model Evolution - Why The Journey To SaaS Makes Sense
Programming With WinRT And Windows8
Michael Kiener Associates Ltd
Vertaalbureau Perfect
Telerik Kendo UI vs. AngularJS
Sculptura in coaja de ou
Cloud computing was bringt's
Ad

Similar to Whats New in Visual Studio 2012 for C++ Developers (20)

PDF
Unmanaged Parallelization via P/Invoke
PPT
Pragmatic Model Driven Development using openArchitectureWare
PPTX
Framework engineering JCO 2011
PDF
Experience with C++11 in ArangoDB
PPTX
.NET 4 Demystified - Sandeep Joshi
PPT
Linq 1224887336792847 9
PPT
Linq To The Enterprise
PPT
Migration To Multi Core - Parallel Programming Models
PPTX
Gude for C++11 in Apache Traffic Server
PPTX
The Style of C++ 11
PDF
Hybrid Cloud, Kubeflow and Tensorflow Extended [TFX]
PPT
Smalltalk in a .NET World
PPTX
Advance Android Application Development
PDF
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
PDF
LibOS as a regression test framework for Linux networking #netdev1.1
PPTX
SQL Server - CLR integration
PPTX
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
PPTX
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
PPT
Sadiq786
PDF
Bounded Model Checking for C Programs in an Enterprise Environment
Unmanaged Parallelization via P/Invoke
Pragmatic Model Driven Development using openArchitectureWare
Framework engineering JCO 2011
Experience with C++11 in ArangoDB
.NET 4 Demystified - Sandeep Joshi
Linq 1224887336792847 9
Linq To The Enterprise
Migration To Multi Core - Parallel Programming Models
Gude for C++11 in Apache Traffic Server
The Style of C++ 11
Hybrid Cloud, Kubeflow and Tensorflow Extended [TFX]
Smalltalk in a .NET World
Advance Android Application Development
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
LibOS as a regression test framework for Linux networking #netdev1.1
SQL Server - CLR integration
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
Sadiq786
Bounded Model Checking for C Programs in an Enterprise Environment

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PPTX
Cloud computing and distributed systems.
PDF
Empathic Computing: Creating Shared Understanding
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Modernizing your data center with Dell and AMD
PPTX
A Presentation on Artificial Intelligence
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PPT
Teaching material agriculture food technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Big Data Technologies - Introduction.pptx
Electronic commerce courselecture one. Pdf
Cloud computing and distributed systems.
Empathic Computing: Creating Shared Understanding
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Modernizing your data center with Dell and AMD
A Presentation on Artificial Intelligence
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
The Rise and Fall of 3GPP – Time for a Sabbatical?
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
MYSQL Presentation for SQL database connectivity
Teaching material agriculture food technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Machine learning based COVID-19 study performance prediction
Encapsulation_ Review paper, used for researhc scholars
Mobile App Security Testing_ A Comprehensive Guide.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Big Data Technologies - Introduction.pptx

Whats New in Visual Studio 2012 for C++ Developers

  • 1. Philipp Aumayr software architects gmbh Web http://www.timecockpit.com Mail philipp@timecockpit.com Visual C++ 2012 Twitter @paumayr Improvements over 2008 Saves the day.
  • 2. Intro  DI Philipp Aumayr  Senior Developer @ software architects (time cockpit)  9-5 -> C#, 5->9 C++, 24/7 VS 2012  Twitter: @paumayr  Blog: http://www.timecockpit.com/devblog/
  • 3. Motivation  Visual Studio 2012 improvements over 2008 New Shell New Editor Better Intellisense Unit Testing Code Coverage Code Analysis #include completion Navigate To Type visualizers
  • 4. Motivation  C++11 New standard released August 12, 2011 Major overhaul Bjarne Stroustrup: „C++11 feels like a new language“ Visual Studio 2012 has partial support Is updated out-of-band (November CTP adds major language parts) auto, decltype, range-based for loop lambdas, explicit overrides, static_assert nullptr, enum classes, move-semantics, variadic templates, initializer_lists, delegating constructors, explicit conversion operators
  • 5. Motivation  STL improvements shared_ptr, unique_ptr unordered_set, unordered_map SCARY iterators + container sizes  Move Semantics  std::async  Code Analysis  SDL
  • 6. Motivation  Auto-vectorization  Auto-parallelization  C++ AMP A lot to learn, but well worth the effort!
  • 7. IDE Improvements  Multi-monitor support Rewritten in WPF and MEF  Improved responsiveness Intellisense works in the background Asynchronous project loading  Editor Zooming  Navigate-To  Call Hierarchy  Demo
  • 8. IDE Improvements  Preview tab  Pinned editor windows  Ctrl + Q / Search Menu  New Solution explorer Scope to this multiple views  Find within editor  Find all references  Demo
  • 9. Test Framework  Supports writing unit tests for MSTest Test adapters for other test frameworks are available Gtest xUnit++  Test Explorer Window Grouping  Code Coverage  Demo
  • 10. Better Intellisense  Uses an SDF (SQL CE database) instead of the ncb  Faster  More robust  Demo
  • 11. Type Visualizers (Natvis)  Allow customizable data representation in debugger Replaces autoexp.dat Easier to handle, more powerful  Create a natvis file Place in either %VSINSTALLDIR%Common7PackagesDebuggerVisualizers (requires admin access) %USERPROFILE%My DocumentsVisual Studio 2012Visualizers Or VS extension folders  Files are reloaded at every debugging session No restart required when changing natvis files
  • 12. Type Visualizers (Natvis)  Example natvis file  Allows conditional strings, node expansions, item lists, tree items, synthetic items, etc.
  • 13. Break New Editor Better Intellisense Unit Testing Code Coverage Code Analysis #include completion Navigate To Type visualizers
  • 15. C++ Styles (Question) C with a C++ compiler? C with classes / inheritance?  RAII, Exceptions, Smart pointer?  STL?  TMP?
  • 16. auto  Automatically deduces type information Very similar to „var‟ in c# Reduces amount of typing required  Reference or Value? Value by default, add & to make it a reference  Demo
  • 17. decltype  Represents the type of the expression decltype(2*3) -> int decltype(a) -> type of a  Why? Let types flow!  Demo
  • 18. Range based for loop  New type of for loop  Iterates all members of a collection  Demo
  • 19. Lambdas  Anonymous Functions  Allows logic to be placed where required  Can capture environment  General syntax: [capture](parameters)->return-type{body}  represent by type std::function<>
  • 20. Lambdas  Finally make STL algorithms useable  Reduces amount of (boilerplate-)code No more functor classes!
  • 21. Lambda Captures  A Lambda can capture environment Allows the lambda to access and modify state  Capture kinds - reference or value - automatic or specific  Demo
  • 22. override and final  Explicitly defines overrides Compiler helps if no method to override is found  Helps with refactoring Rename method in base class but not in derived -> derived method no longer overrides Base class from third party!  Helps class design Implementers of derived classes can more easily understand which methods to override  final can be used on classes to prevent being derived from  Demo
  • 24. static_assert  Tests a software assertion at compile time  Especially useful for portable code Assert size of specific structures (x86, x64 issues)  Check library versions  Used to be accomplished using the preprocessor  Demo
  • 25. nullptr 0 / NULL used to indicate a null pointer  nullptr is of type nullptr_t  implicitly assignable to any pointer  not assignable to int etc.
  • 26. enum classes  C++03 enums Not type safe Enums of different types can be compared (basically integers) Storage type int  C++11 enum classes Type is compared as well! Underlying type can be chosen
  • 28. enum classes  C++11 enum classes
  • 30. Initializer lists (CTP)  Eases construction of non-POD types  Finalversion will provide initialize list constructors for STL types  Binds {…} syntax to the std::initializer_list<T> type.  Current STL does not support it  Demo name == “class std::initializer_list<int>”
  • 31. variadic templates (CTP)  Flexible number of template arguments  Usable for template writers n-ary structures (tuples) e.g. make_shared, make_tuple Example: saveprint  Beware of dragons ;)  Demo
  • 32. Move Semantics  C++03: many (temporary) class instances Resulted in a lot of copying Constructs to work around Passing complex data structure from function  C++11: Move semantics If the copied value is an rvalue reference, the move constructor is called
  • 33. Move Semantics  Dramatically changes style! C++03 C++11
  • 34. Move Semantics  Note: right-hand version is valid C++03 code! But advanced programmers avoided it, due to the extra copy involved.  Now with C++11: Elegant AND Fast Reconsider the patterns you are used to  All STL containers implement move semantics Returning container was unavoidable? -> automatic performance improvement!  STL code will have fewer temporary objects  Demo
  • 35. Break  C++11 auto, decltype, range-based for loop lambdas, explicit overrides, static_assert nullptr, variadic templates, initializer_lists, enum classes, move-semantics
  • 36. std::async  C++ 11 has built-in support for asynchrony available through <future> header  std::async<T>(std::function) returns a future<T> - Different launch policies (synchronous, asynchronous) - can be waited on using wait() or get() to retrieve the result  Implemented in VC++ using PPL (parallel patterns library) - Highly scalable and performant
  • 37. std::async  Not every asynchronous operation is a thread / cpu bound Notably IO requests User Input etc.  std::future<T> can be created from a std::promise<T>!  std::promise<T> acts as a provider for a future Marshalls result between threads of execution correct locking / etc. Provides set_value / set_exception
  • 38. std::async T1 T2 (Blocks) Demo
  • 39. Parallel Patterns Library  Based on ConcRT  Compatible to Intel Thread Building Blocks (TBB) At least interface wise  Template Library for parallel programming Abstracts concurrent workflows into tasks Provides continuations (improvement over std::future<T>)  Demo
  • 40. Auto Vectorization  Modern CPUs support SIMD Single Instruction Multiple Data Extensions such as SSE and AVX Usually optimized for specifically using compiler intrinsics or inline assembler Serial Vector x = x1 + x2 xyzw = xyzw1 + xyzw2 y = y1 + y2 z = z1 + z2 w = w1 + w2 τ
  • 41. Auto Vectorization  VC++ 2012 compiler has an auto-vectorizer (-Qvec) Tries to automatically vectorize loops and operators Enabled by default Diagnosis output using /Qvec-report:2  Performance difference? Depends. Max 4x for SSE (128bit), 8x for AVX (256bit), 3x-4x typical  Demo (later with auto parallelization)
  • 42. Auto-Parallelization  To utilize multiple cores, parallelization is used (MIMD) Multiple-Instructions-Multiple-Data  VC++2012 has an auto-parallelizer Can be hinted #pragma loop(hint_parallel(N)) #pragma loop(ivdep) Enabled using /Qpar Diagnosis using /Qpar-report:2  Demo
  • 43. C++ AMP  Open specification created by Microsoft  C++ for GPGPU Massively Parallel / Vector programming Based on top of DirectCompute (windows) Clang / LLVM implementation using OpenCL is available Provided by Intel (“Shevlin Park”)  One new keyword Restricts the decorated function to a specific subset of c++  Template library for wrapping data structures Datatransfer to/from GPU etc.
  • 44. Why C++ AMP?  Directly available from the compiler No additional SDK required Can reuse types (vector2f e.g.)  Better debugging experience compared to CUDA / OpenCL!  Makes C++ applicable to heterogeneous computing A processor may consist of multiple cores of different flavor More energy efficient (mobile!) visual computing image morphing Augmented reality etc.  Demo
  • 45. Smaller container sizes  X86 release, sizes in bytes Container VC9 SP1 / SCL = 0 VC10 (2010) VC11 (2012) (2008) vector<int> 16 16 12 deque<int> 32 24 20 forward_list<int> N/A 8 4 queue<int> 32 24 20 stack<int> 32 24 20 unordered_map<int, int> 44 44 32 string 28 28 24 wstring 28 28 24 ~14% less!
  • 46. Smaller container sizes  x64 release, sizes in bytes Container VC9 SP1 / SCL = 0 VC10 (2010) VC11 (2012) (2008) vector<int> 32 32 24 deque<int> 64 48 40 forward_list<int> N/A 16 8 queue<int> 64 48 40 stack<int> 64 48 40 unordered_map<int, int> 88 88 64 string 40 40 32 wstring 40 40 32 ~20% less!
  • 47. Code Analysis  Static analysis  Provides warnings at compile time  Additionally to /GS and /SDL  Detailed information on warning
  • 48. Code Analysis  What does it check ? Uninitialized Reads HRESULT verification checks Concurrency Warnings Format string checks Correct destructor calls (delete[] vs delete) Redundant code checks Many more: http://msdn.microsoft.com/en-us/library/a5b9aa09.aspx  Custom code can be annotated to aid code analysis See http://msdn.microsoft.com/en-us/library/ms182032.aspx  Demo
  • 49. Break  std::async  ppl  auto vectorization  auto parallelization  container sizes  code analysis
  • 50. Custom Snippets  .snippet is supported, same as C# XML file describing a code snippet Declare variables and use them in the snippet body  Very helpful for similar but not equivalent code  Demo
  • 51. Debug View  Pin watch to source code Add comments Not only variables, but (most) expressions  View values from last debug session  Export / Import Data Tips Makes it easier for debugging with multiple developers / on different machines  Demo
  • 52. Parallel Stacks Window  New view for debugging  Better understanding of multi thread applications
  • 53. Parallel Tasks Window  Lists the task queues
  • 54. Parallel Watch Window  Watch expressions in parallel Especially useful in tight loops Data races Expressions Can freeze / thaw threads Manually verify locking  Demo Parallel Stacks Parallel Tasks Threads Parallel Watch
  • 55. Shortcuts Shortcut Action Shortcut Strg + , Navigate To Strg + Q Search Menu F12 Go To Definition Strg + K, C Comment lines Umschalt + F12 Find all references Strg + K, U Uncomment lines Strg + - Navigate Backwards Strg + M, O Collapse To definition Strg + Umschalt + - Navigate Forwards Strg +M, X Expand All Outlining Strg + F Find in current file Strg +M, S Collapse Current Region Strg + H Replace in current file Strg + M, E Expand Current Region
  • 56. Break  Custom snippets  Debug view experience  Parallel Stacks  Parallel Tasks  Parallel Watch Window  code analysis  Shortcuts
  • 57. What‟s next?  It‟s a good century for C++ / native developers Single thread performance isn‟t getting much better memory latency / bandwidth is the bottleneck Efficiency is becoming more important (mobile!)  There is a huge commitment towards C++ Google, Apple started a new compiler project a few years ago (Clang / LLVM) ISO standard is evolving more quickly C++ Standards Foundation (www.isocpp.org) Google, Apple, Intel, Microsoft, ARM, IBM, HP, etc.
  • 58. Upcoming Standards  Library in std:: for file system handling based on boost.filesystem v3 We are here!  Net TS Networking HTTP etc.  TM TS Transactional Memory
  • 59. Wrap-Up  Tour around the new IDE  New Library Features Shell / Window handling std::async Solution Explorer PPL Code Navigation Improved container sizes Better Intellisense Snippets, Debug Experience Parallel Watch, Threads, Tasks  New Compiler Features  New Language Features Code Analysis auto, decltype, lambdas, /SDL /GS override, final Auto Vectorization static_assert, nullptr Auto parallelization C++ AMP
  • 60. Philipp Aumayr software architects gmbh Q&A Mail philipp@timecockpit.com Web http://www.timecockpit.com Twitter @paumayr Thank your for coming! Saves the day.

Editor's Notes

  • #8: Snap window back to original: Ctrl + Double click headerPromoting Preview Tab -&gt; Ctrl + Alt + Home (Pos1)
  • #9: Promoting Preview Tab -&gt; Ctrl + Alt + Home (Pos1)Show Themes (Dark / Light)
  • #10: Demo: Open VC2012 solution, add a few Assert::Fail to make testing more interesting. Show what test classes are
  • #11: Demo: Open up Ogre SDK -&gt; show that included Ogre.h works for intellisense
  • #12: [HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\11.0_Config\\Debugger]&quot;EnableNatvisDiagnostics&quot;=dword:00000001
  • #13: [HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\11.0_Config\\Debugger]&quot;EnableNatvisDiagnostics&quot;=dword:00000001http://msdn.microsoft.com/en-us/library/vstudio/jj620914.aspx
  • #17: VC2012:TestAuto, TestAuto2, show types in intellisense
  • #18: Demo: TestDeclType, show types of variables using hover
  • #19: Demo:TestRangeBasedForLoop, TestRangeBasedForLoopArray, TestRangeBasedForLoopCustomRange
  • #21: Demo: TestLambdaFunctionAdd, TestLambdaFunctionCaptureValue, TestLambdaFunctionCaptureReference, TestLambdaFunctionMultiCapture, TestLambdaFunctionPassToFunction
  • #22: Demo: TestLambdaFunctionAdd, TestLambdaFunctionCaptureValue, TestLambdaFunctionCaptureReference, TestLambdaFunctionMultiCapture, TestLambdaFunctionPassToFunction
  • #31: Demo: TestInitializerList
  • #32: Demo: VC2012CTP.cpp
  • #35: Demo: TestMoveConstructor
  • #39: Demo: TestAsync, TestPromise, TestTaskPPL
  • #40: Demo: TestTaskPPL
  • #43: Demo: VC2012 -&gt; main.cppQvec / Qparmessages http://msdn.microsoft.com/en-us/library/jj658585.aspx
  • #45: Demo: VC2012 -&gt; uncomment AMP
  • #49: http://msdn.microsoft.com/en-us/library/a5b9aa09.aspxDemo: ArrayOfByOne, RedundantCodeCheck
  • #52: Intvector.snippet, debugging support
  • #54: Demo: break in TestAsync