slide1 l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Required Slide PowerPoint Presentation
Download Presentation
Required Slide

Loading in 2 Seconds...

play fullscreen
1 / 27

Required Slide - PowerPoint PPT Presentation


  • 108 Views
  • Uploaded on

Required Slide. Required Slide. DEV311 Modern Programming with C++0x in Microsoft Visual C++ 2010. Kate Gregory Gregory Consulting www.gregcons.com/kateblog, @ gregcons. Agenda. Language and Library updates C++0x and TR1 Lambdas, auto unique_ptr , make_shared IDE improvements

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Required Slide' - catori


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
dev311 modern programming with c 0x in microsoft visual c 2010

Required Slide

DEV311Modern Programming with C++0x in Microsoft Visual C++ 2010

Kate Gregory

Gregory Consulting

www.gregcons.com/kateblog, @gregcons

agenda
Agenda
  • Language and Library updates
    • C++0x and TR1
    • Lambdas, auto
    • unique_ptr, make_shared
  • IDE improvements
    • Intellisense – no ncb
    • Navigate To , red squiggles
  • Concurrency
    • PPL
    • New debug windows
    • Concurrency profiler
  • What there isn’t time for
    • MFC Updates
      • Ribbon designer
      • Windows 7 support
    • shared_ptr, nullptr
    • Rvalue references, move constructors, std::move
    • More library additions egcopy_if, is_sortedetc
tr1 and c 0x
TR1 and C++0x
  • TR1 is Technical Report 1, released in 2005
  • C++0x is the upcoming C++ standard
  • Some of each were added in Visual C++ 2008 SP 1
    • (VC9SP1)
  • More are now in Visual C++ 2010
    • (VC10)
lambdas for c
Lambdas for C++
  • What’s a Lambda?
  • Lambda expression or lambda function: an expression that specifies an anonymous function object
  • Imagine handing an operation or function (code) to some other operation or function
    • For generic work
    • For a functional style
    • For concurrency
    • For readability
      • Eliminate tiny functions
tiny functions
Tiny Functions
  • void print_square(int i)
  • {
  • cout << i*i << endl;
  • }
  • int main()
  • {
  • vector<int> v;
  • for_each(v.begin(), v.end(), print_square);
  • }
why does it need a name
Why Does It Need a Name?
  • intmain() {
  • vector<int> v;
  • for_each(v.begin(), v.end(),
  • [](int i) { cout << i*i << endl; } );
  • }
lambdas

Lambdas

demo

lambdas that return something
Lambdas That Return Something
  • vector<int> v;
  • deque<int> d;
  • transform(v.begin(), v.end(),
  • front_inserter(d),
  • [](int n) { return n * n * n; });
  • transform(v.begin(), v.end(),
  • front_inserter(d),
  • [](int n) -> double {
  •         if (n % 2 == 0) {return n * n * n;}
  • else {return n / 2.0;}
  •     });
using variables from local scope
Using Variables from Local Scope
  • v.erase(remove_if(v.begin(), v.end(),
  • [x, y](int n) { return x < n && n < y; }),v.end());
  • v.erase(remove_if(v.begin(), v.end(),
  • [=](int n) { return x < n && n < y; }), v.end());
  • for_each(v.begin(), v.end(),
  • [&x, &y](int& r) {
  • constint old = r;
  •         r *= 2;
  •         x = y;
  •         y = old;     });
a uto
Auto
  • Automatic type deduction

auto x = new HugeObject(42);

  • No more gnarly iterator declarations

for (auto it = v.begin(); it != v.end(); ++it)

  • Powered by template argument deduction rules
    • const auto* p = new foo and const auto& r = bar work
c 0x standard library in vc 2010
C++0x Standard Library in VC 2010
  • Rvalue references
    • vector reallocation, etc. exploits move semantics
    • Perfect forwarding: make_shared<T>(), etc.
    • Std::move
    • unique_ptr
  • New member functions: cbegin(), cend(), etc.
  • New algorithms: copy_if(), is_sorted(), etc.
  • Code conversions: <codecvt>
  • Exception propagation: exception_ptr
  • Diagnostics: <system_error>
smart pointers
Smart pointers
  • shared_ptr
    • Arrived in VC9 SP1
    • In VC10: make_shared
  • unique_ptr
    • Like a shared_ptr without the sharing
make shared t
make_shared<T>()
  • VC9 SP1:
    • shared_ptr<T> sp(new T(args));
    • shared_ptr<T> sp(new T(args), del, alloc);
  • VC10:
    • auto sp = make_shared<T>(args);
    • auto sp = allocate_shared<T>(alloc, args);
unique ptr
unique_ptr
  • Supersedes auto_ptr, which is now deprecated
  • Lightweight and performant
    • No reference counting overhead
  • Noncopyable but movable
  • Works just fine in containers
const iterators cbegin and cend
Const iterators: cbegin and cend
  • vector<int> v;
  • for (auto i = v.begin(); i != v.end(); ++i) {
  • // i is vector<int>::iterator
  • }
  • for (auto i = v.cbegin(); i != v.cend(); ++i) {
  • // i is vector<int>::const_iterator
  • }
visual studio 2010 architecture changes
Visual Studio 2010 Architecture Changes
  • Intellisense decoupled from navigation
    • No need to reparse entire solution after header change
  • No more .ncb file – SQL CE store instead
    • Much quicker to insert/update single symbol
  • Intellisense faster even in larger solutions
    • After a small code change
    • Switching build (e.g., debug to release)
visual studio 2010 new features
Visual Studio 2010 New Features
  • Navigate To
    • Find a symbol
  • Red Squiggles
    • Without a build
  • Call Hierarchy
    • Calls From
    • Calls To
    • Replaces Call Browser
native concurrency stack
Native Concurrency Stack

C/C++ Application or Library

Parallel Pattern Library

parallel_for

parallel_for_each

Concurrent Algorithms

parallel_accumulate

parallel_partialsum

parallel_invoke

Messaging Primitives

send, receive

asend, try_receive

message buffers

Concurrent Collections

concurrent_queue

concurrent_vector

concurrent_hash_map

Concurrency Primitives

task handles

task groups

futures

synchronization types

Concurrency Runtime

Schedulers with Work-Stealing Queues

chores

chores

Resource Manager

Threads + UMS

Proc 1

Proc p

c is very m uch a live
C++ Is Very Much Alive
  • Native code is still a fully supported way of life
  • Interop is dramatically easier from C++
  • Templates offer power no other language can match
    • For both native-only and interop development
  • Microsoft is committed to C++
    • IDE improvements
    • MFC improvements
    • Language-level improvements
track resources

Required Slide

Track PMs will supply the content for this slide, which will be inserted during the final scrub.

Track Resources
  • Resource 1
  • Resource 2
  • Resource 3
  • Resource 4
resources

Required Slide

Resources

Learning

  • Sessions On-Demand & Community
  • Microsoft Certification & Training Resources

www.microsoft.com/teched

www.microsoft.com/learning

  • Resources for IT Professionals
  • Resources for Developers
  • http://microsoft.com/technet
  • http://microsoft.com/msdn
related content

Required Slide

Speakers, please list the Breakout Sessions, Interactive Sessions, Labs and Demo Stations that are related to your session.

Related Content
  • Breakout Sessions
  • Product Demo Stations
session evaluations

Session Evaluations

Tell us what you think, and you could win!

All evaluations submitted are automatically entered into a daily prize draw* 

Sign-in to the Schedule Builder at http://europe.msteched.com/topic/list/

* Details of prize draw rules can be obtained from the Information Desk.

slide27

© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.