cplusplus:sdwest2006
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Next revision | |||
— | cplusplus:sdwest2006 [2012/01/27 00:14] – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Notes from SD West 2006 ====== | ||
+ | I went to the C++ Tuturial with [[http:// | ||
+ | |||
+ | Bjarne was once challenged by Adobe to explain why C++ succeeded for over 25 years with no cash or power. | ||
+ | |||
+ | ===== TR1 Library Extensions ===== | ||
+ | The namespace is currently std::tr1. | ||
+ | |||
+ | ==== shared_ptr ==== | ||
+ | * Deleter object | ||
+ | * Casts | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | ==== binders ==== | ||
+ | They mostly suck. (As compared to lambda.) | ||
+ | |||
+ | < | ||
+ | find_if(v.begin(), | ||
+ | bind(equal_to< | ||
+ | bind(& | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | ==== function ==== | ||
+ | A function wrapper. | ||
+ | < | ||
+ | pthread_once(pthread_once_t*, | ||
+ | pthread_once(pthread_once_t*, | ||
+ | </ | ||
+ | |||
+ | ==== regex ==== | ||
+ | Just like in python. | ||
+ | |||
+ | ==== random ==== | ||
+ | Separates the generators (distribution settings) from the engines. | ||
+ | |||
+ | ===== Performance ===== | ||
+ | |||
+ | Bjarne presented a slide in " | ||
+ | |||
+ | **Bad Use** | ||
+ | < | ||
+ | struct Link { | ||
+ | Link * link; | ||
+ | void * data; | ||
+ | }; | ||
+ | |||
+ | void my_clear(Link *p, int sz) | ||
+ | { | ||
+ | for (Link *q = p; q != 0; q = q->link) | ||
+ | memset(q-> | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | **Better Use** | ||
+ | < | ||
+ | template< | ||
+ | void my_stl_clear(forward_it first, forward_it last, const T &v) | ||
+ | { | ||
+ | while (first != last) *first++ = v; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | The idea here being that with type info, the compiler can optimize, inline and allow for caching far better than when having to deal with typeless (void) info. The object copy was on the order of 2 to 4x faster. | ||
+ | |||
+ | The gold standard in numbers crunching performance is Fortran, and Bjarne demonstrated how C++ can beat simple number crunching by providing the compiler with static type info to allow it to optimize cache usage. | ||
+ | |||
+ | This also goes to the fact that we should prefer function objects over raw functions when using the STL. | ||
+ | |||
+ | ===== Template Constraints ===== | ||
+ | |||
+ | Template constraints can be used to provide qualifying information for templates, and will help make error messages far more easy to read. Eg., | ||
+ | |||
+ | < | ||
+ | template< | ||
+ | static void constrants(T a, T b) { a<b; a<=b; } // constraint check | ||
+ | Comparable() { void (*p)(T,T) = constrants; } // trigger the constraint | ||
+ | }; | ||
+ | |||
+ | template< | ||
+ | : private Comparable< | ||
+ | }; | ||
+ | |||
+ | Range< | ||
+ | Range< | ||
+ | </ | ||
+ | |||
+ | ===== Lambda ===== | ||
+ | Bjarne gave an example of lambda. | ||
+ | |||
+ | ===== RAII ===== | ||
+ | RAII, as always, got a lot of emphasis. | ||
+ | |||
+ | ===== Abstract Classes ===== | ||
+ | Provided as the solution to the common circle and triangle inherit from a stateful base shape class. | ||
+ | |||
+ | ===== Concurrency ===== | ||
+ | Sutter' | ||
+ | |||
+ | ===== Concepts C++/0x ===== | ||
+ | "A type system for C++ types." | ||
+ | |||
+ | < | ||
+ | template< | ||
+ | where Assignable< | ||
+ | void fill(For first, For last, const V& v); // <-- just a declaration, | ||
+ | </ | ||
+ | |||
+ | ===== Other C++/0x ===== | ||
+ | |||
+ | < | ||
+ | template< | ||
+ | |||
+ | sort(v); | ||
+ | |||
+ | for(auto p = v.begin(); p != v.end(); ++p) cout << *p << endl; // auto! | ||
+ | |||
+ | vector< | ||
+ | </ | ||
+ | |||
+ | ===== Exception Safety ===== | ||
+ | |||
+ | - Basic Guarantee -> Invariants are maintained. | ||
+ | - Strong Guarantee -> Either success, or no effect. | ||
+ | - No throw Guarantee -> The operation cannot throw. | ||
+ | |||
+ | Do the risky work off the the side, then commit with swap. (And benefit from C++0x' | ||
+ | |||
+ | Bjarne' | ||
+ | < | ||
+ | template< | ||
+ | { | ||
+ | swap(a,b); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== TODO ===== | ||
+ | |||
+ | * Add LJ Best Practices Page | ||
+ | * Add space for Burt's Macintosh Convention | ||
+ | * Investigate '' | ||
+ | * Investigate //swine// | ||
+ | * Document migration from Perspective to DokuWiki | ||
+ | * Expo Guide mentions a ruby installer http:// | ||
+ | |||
+ | ===== NOTES ===== | ||
+ | |||
+ | * I've got a sample chapter from Pete Becker' | ||
+ | * Bjarn Stroustrup agrees with WinDump powerpoint presentation, | ||
+ | |||
+ | ===== Humorous ===== | ||
+ | |||
+ | * Stroustrup not hot on the CLI. (Not a good idea.) | ||
+ | * Stroustrup thinks Andrei Alexandrescu is weird, while Herb reveres him. | ||
+ | * Sutter (and Bjarne) repeatedly uses Python as a goal for the future of C++ libraries, and used Python as the example for the TR1 regex library in C++. | ||
+ | |||
+ | * Sutter got really animated when one attendee suggested he heard that C# outperformed C++ at something. | ||
+ | * Sutter uses: | ||
+ | * Microsoft PowerPoint, (as did every presenter) | ||
+ | * but had a Macintosh skin on his OS | ||
+ | * used Google (not MSN, Start, or other MS) | ||
+ | * used linux virtual machine for code samples | ||
+ | * Browsed with Firefox. |
cplusplus/sdwest2006.txt · Last modified: 2023/04/12 20:44 by 127.0.0.1