36 out of 41 rated this helpful - Rate this topic

What's New for Visual C++ in Visual Studio 11 Beta

Visual Studio 11

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

This document introduces new and enhanced Visual C++ features in Visual Studio 11 Beta.

For information about other additions in Visual Studio 11 Beta, see What's New in Visual Studio 11 Beta.

Note Note

For information about integrated development environment (IDE) features for developers who are creating Windows Metro style apps, see Tour of the IDE for C#/C++/Visual Basic Developers or Tour of the IDE for Javascript Developers.

Standard Template Library

To support the C++11 specification, the Standard Template Library (STL) in Visual Studio is extended to provide the additional programming constructs that C++11 requires. Here are the highlights:

  • Support for new headers: <atomic>, <chrono>, <condition_variable>, <filesystem>, <future>, <mutex>, <ratio>, and <thread>.

  • To optimize memory resource usage, containers are now smaller. For example, in x86 release mode with default settings, std::vector has shrunk from 16 bytes in Visual C++ 2010 to 12 bytes in Visual C++ in Visual Studio 11 Beta, and std::map has shrunk from 16 bytes in Visual C++ 2010 to 8 bytes in Visual C++ in Visual Studio 11 Beta.

Other C++11 Enhancements

  • Range-based for loops. You can write more robust loops that work with arrays, STL containers, and—when collection.h is included—Windows Runtime collections in the form for ( for-range-declaration : expression ). This is part of the Core Language support.

  • SCARY iterators. As permitted but not required by the C++11 Standard, SCARY iterators have been implemented. For more information, see the PDF document SCARY Iterator Assignment and Initialization.

  • Stateless lambdas, which are blocks of code that begin with an empty lambda introducer [] and capture no local variables, are now implicitly convertible to function pointers as required by the C++11 Standard.

  • Scoped enumerations support. The C++ enum class enum-key is now supported.

  • Auto-vectorizer. One of the biggest potential performance gains is doing things in parallel instead of sequentially. Visual Studio 11 Beta provides not only parallelism on the task level, but also at the loop level, automatically. The C++ compiler automatically vectorizes loops if it can. Vectorization reorganizes a loop, for example, a summation loop, so that the CPU can execute multiple iterations at the same time. By using auto-vectorization, loops can be up to eight times faster when they are executed on CPUs that support SIMD instructions. For example, most modern processors support SSE2 instructions, which enable the compiler to instruct the processor to do math operations on four numbers at a time.

    Because the compiler recognizes loops that can be vectorized when you compile your code, this occurs automatically. This differs from parallelization, which is described in the next list item.

  • Auto-parallelizer. Visual Studio 11 Beta improves how you can take advantage of multiprocessor and multi-core hardware. By using the auto-parallelizer, a loop is reorganized so that it can be executed on multiple threads at the same time. This means that your app can take advantage of multi-core CPUs and multiprocessors to distribute chunks of the work to all available processors. You don't have to add any code—the parallelizer automatically reorganizes loops and executes multiple tasks. You can use the #pragma parallelize directive to tell the compiler which loops to parallelize.

    There are some key differences between auto-vectorization and auto-parallelization. Auto-vectorization is always on and requires no user interaction, but auto-parallelization requires the programmer to decide which loops are to be parallelized. Also, vectorization improves the performance of loops on single-core CPUs that support SIMD instructions, but parallelization improves the performance of the loop on multiple CPUs and multi-core CPUs. The two features can work together so that a vectorized loop is then parallelized across multiple processors.

  • C++ Accelerated Massive Parallelism (AMP) Support. C++ AMP accelerates the execution of your C++ code by taking advantage of the data-parallel hardware that's ordinarily present as a GPU on a discrete graphics card. The C++ AMP programming model includes multidimensional arrays, indexing, memory transfer, tiling, and a mathematical function library. By using C++ AMP language extensions and compiler restrictions, you can control how data is moved from the CPU to the GPU and back. For more information, see C++ Accelerated Massive Parallelism (C++ AMP).

Parallel Programming Improvements

With hardware moving to multi-core and many-core architectures, developers can no longer rely on ever-increasing clock speeds from single-cores. The parallel programming support in the Concurrency Runtime enables developers to take advantage of these new architectures.

In Visual Studio 2010, powerful C++ parallelization libraries such as the Parallel Patterns Library were introduced, together with features to take advantage of concurrency by expressing sophisticated dataflow pipelines. In Visual Studio 11 Beta, these libraries have been extended to provide better performance, more control, and richer support for the parallel patterns that developers need most. The breadth of the offering now includes:

  • A rich task-based programming model that supports asynchrony and continuations. For more information, see Task Parallelism (Concurrency Runtime).

  • Parallel Algorithms , which support fork-join parallelism (parallel_for, parallel_for with affinity, parallel_for_each, parallel_sort, parallel_reduce, parallel_transform).

  • Concurrency-safe containers, which provide thread-safe versions of std data structures such as priority_queue, queue, vector, and map.

  • The Asynchronous Agents Library, which developers can use to express dataflow pipelines that naturally decompose into concurrent units.

  • A customizable scheduler and resource manager to facilitate the smooth composition of the patterns in this list.

The tools in the Visual Studio IDE have significant improvements to help you be more productive when you code in C++. For more information about IDE enhancements, see Product Highlights for Visual Studio 11 Beta.

  • Visual Studio Templates support. You can now use the Visual Studio Templates technology to author C++ project and item templates.

  • Automated deployment for remote debugging. Deployment of files for remote debugging in Visual C++ has been simplified. The Deploy option on the project context menu automatically copies to the remote computer the files that are specified in the debugging configuration properties. Copying files manually to the remote computer is no longer required. For more information, see Remote Debugging of a Project Built Locally.

  • C++/CLI IntelliSense. C++/CLI now has full IntelliSense support. IntelliSense features such as Quick Info, Parameter Help, List Members, and Auto Completion now work for C++/CLI. In addition, the other IntelliSense and IDE enhancements listed in this document also work for C++/CLI.

  • C++ Code Snippets. Skeleton code is available for switch, if-else, for loop, and other basic code constructs, in the List Members drop-down list. Select a code snippet from the list to insert it into your code and then fill in the required logic. You can also create your own custom code snippets for use in the editor. For more information, see Code Snippets.

  • List Members Enhancements. The List Members drop-down list appears automatically as you type code into the code editor. Results are filtered, so that only relevant members are displayed as you type. You can control the kind of filtering logic that's used by the Member List—in the Options dialog box under Text Editor, C/C++, Advanced. For more information, see Using IntelliSense.

  • Semantic Colorization. Types, enumerations, macros, and other C++ tokens now have colorization by default. For more information, see Code and Text Editor.

  • Reference Highlighting. Selecting a symbol now highlights all instances of the symbol in the current file. Press Ctrl+Shift+Up Arrow or Ctrl+Shift+Down Arrow to move among the highlighted references. You can turn this feature off in the Options dialog box, under Text Editor, C/C++, Advanced.

Parallel Debugging

In addition to the Parallel Tasks window and Parallel Stacks window, Visual Studio 11 Beta offers a new Parallel Watch window so that you can examine the values of an expression across all threads and processes, and perform sorting and filtering on the result. You can also use your own visualizers to extend the window, and you can take advantage of the new multi-process support across all tool windows.

C++ Accelerated Massive Parallelism (AMP) Debugging and Profiling

Debugging. The debugging experience for apps that use C++ AMP to target the GPU is just like debugging for other C++ apps. This includes the new parallel debugging additions that were mentioned earlier.

Profiling. There is now profiling support for GPU activity that's based on C++ AMP and other Direct3D-based programming models.

Static Code Analysis

Static analysis for C++ has been updated to provide richer error context information, more analysis rules, and better analysis results. In the new Code Analysis window, you can filter messages by keyword, project, and severity. When you select a message in the window, the line in the code where the message was triggered is highlighted in the code editor. For certain C++ warnings, the message lists source lines to show you the execution path that led to the warning.

Here are some other code analysis enhancements:

  • New concurrency warnings help you make sure that you are using the correct locking disciplines in multithreaded C/C++ programs. The analyzer detects potential race conditions, lock order inversions, caller/callee locking contract violations, mismatched synchronization operations, and other concurrency bugs.

  • You can specify the C++ rules that you want to apply to code analysis runs by using rule sets.

  • In the Code Analysis window, you can insert into the source code a pragma that suppresses a selected warning.

For more information, see Analyzing Application Quality by Using Code Analysis Tools.

Updated Unit Test Framework

Use the new C++ unit test framework in Visual Studio to write C++ unit tests. Add a new unit test project to your existing C++ solution by locating the C++ Unit Test Project template under the Visual C++ category in the New Project dialog box. Start writing your unit tests in the generated TEST_METHOD code stub in the Unittest1.cpp file. When the test code is written, build the solution. When you want to run the tests, open a Unit Test Explorer window by choosing View, Other Windows, Unit Test Explorer, and then, on the shortcut menu for the test case you want, choose Run selected test. After the test run finishes, you can view test results and additional stack trace information in the same window.

Architecture Dependency Graphs

To understand your code better, you can now generate dependency graphs for the binary, class, namespace, and include files in a solution. On the menu bar, choose Architecture, Generate Dependency Graph, and then For Solution or For Include File to generate a dependency graph. When the graph generation is complete, you can explore it by expanding each node, learn dependency relationships by moving between nodes, and browse source code by choosing View Content on the shortcut menu for a node. To generate a dependency graph for include files, on the shortcut menu for a *.cpp source code file or *.h header file, choose Generate Graph of Include Files.

Architecture Explorer

By using the Architecture Explorer, you can explore the assets in your C++ solution, projects, or files. On the menu bar, choose Architecture, Windows, Architecture Explorer. You can select a node you are interested in, for example, Class View. In this case, the right side of the tool window is expanded with a list of namespaces. If you select a namespace, a new column shows a list of the classes, structs, and enums in this namespace. You can continue to explore these assets, or go back to the column on the far left to start another query.

Code Coverage

Code coverage has been updated to dynamically instrument binaries at runtime. This lowers the configuration overhead and provides better performance. You can also collect code-coverage data from unit tests for C++ app. For more information about how to create and run unit tests, see the Unit Test Framework section of this document. When you have created C++ unit tests, you can use Unit Test Explorer to discover tests in your solution. To run the unit tests and collect code coverage data for them, in Unit Test Explorer, choose Analyze Code Coverage. You can examine the code coverage results in the Code Coverage Results window—on the menu bar, choose Test, Windows, Code Coverage Results.

Did you find this helpful?
(1500 characters remaining)