Presentation is loading. Please wait.

Presentation is loading. Please wait.

Kate Gregory Gregory Consulting SESSION CODE: DEV316.

Similar presentations


Presentation on theme: "Kate Gregory Gregory Consulting SESSION CODE: DEV316."— Presentation transcript:

1 Kate Gregory Gregory Consulting www.gregcons.com/kateblog, @gregcons SESSION CODE: DEV316

2

3

4

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; } ); }

7

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; });

10

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

12

13 13

14 14

15

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 }

17

18

19

20

21

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

24

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

26

27


Download ppt "Kate Gregory Gregory Consulting SESSION CODE: DEV316."

Similar presentations


Ads by Google