Download presentation
Presentation is loading. Please wait.
Published byMorgan Griffith Modified over 9 years ago
1
Kate Gregory Gregory Consulting www.gregcons.com/kateblog, @gregcons SESSION CODE: DEV316
5
#include using namespace std; void print_square(int i) { cout << i*i << endl; } int main() { vector v; for_each(v.begin(), v.end(), print_square); }
6
#include using namespace std; int main() { vector v; for_each(v.begin(), v.end(), [](int i) { cout << i*i << endl; } ); }
8
vector v; deque 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; } });
9
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) { const int old = r; r *= 2; x = y; y = old; });
11
Rvalue references vector reallocation, etc. exploits move semantics Perfect forwarding: make_shared (), etc. unique_ptr New member functions: cbegin(), cend(), etc. New algorithms: copy_if(), is_sorted(), etc. Code conversions: Exception propagation: exception_ptr Diagnostics: C++0x Standard Library in VC 2010
13
13
14
14
16
vector v; for (auto i = v.begin(); i != v.end(); ++i) { // i is vector ::iterator } for (auto i = v.cbegin(); i != v.cend(); ++i) { // i is vector ::const_iterator }
22
Required Slide Track PMs will supply the content for this slide, which will be inserted during the final scrub.
23
www.microsoft.com/teched www.microsoft.com/learning http://microsoft.com/technet http://microsoft.com/msdn
25
Sign up for Tech·Ed 2011 and save $500 starting June 8 – June 31 st http://northamerica.msteched.com/registration You can also register at the North America 2011 kiosk located at registration Join us in Atlanta next year
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.