C++ Books

Tuesday, November 6, 2012

Open and Efficient Type Switch for C++

by Yuriy Solodkyy, Gabriel Dos Reis, and Bjarne Stroustrup

Selecting operations based on the run-time type of an object is key to many object-oriented and functional programming techniques. We present a technique for implementing open and efficient type switching on hierarchical extensible data types. The technique is general and copes well with C++ multiple inheritance.

To simplify experimentation and gain realistic performance using production-quality compilers and tool chains, we implement a type switch construct as an ISO C++11 library, called Mach7. This library-only implementation provides concise notation and outperforms the visitor design pattern, commonly used for case analysis on types in object-oriented programming. For closed sets of types, its performance roughly equals equivalent code in functional languages, such as OCaml and Haskell. The type-switching code is easier to use and is more expressive than hand-coded visitors are. The library is non-intrusive and circumvents most of the extensibility restrictions typical of the visitor design pattern. It was motivated by applications involving large, typed, abstract syntax trees.

See also: OOPSLA'12 paper, slides, notes, extras, Mach7 Library

Where do you go to find out about C++?

by Kathy Flores

Texas A&M University's Department of Computer Science and Engineering is one of the founding members of the Standard C++ Foundation. Other founding members of the Foundation are Microsoft, Google, Intel, IBM, HP, ARM, Pearson, Bloomberg, OpenMP, BD Software... The Foundation is a not-for-profit organization with the mission to convey up-to-date information about C++ and to make available both standard and community libraries to developers of modern C++. It does this primarily through its isocpp.org website.

Among the initial contents, you can find a sample from Texas A&M's own Bjarne Stroustrup's forthcoming book: The C++ Programming Language (4th Edition).

The directors and officers of the Foundation are Chandler Carruth (Google) [Treasurer], Beman Dawes (Boost C++ Libraries), Stefanus Du Toit (Intel) [Secretary], Bjarne Stroustrup (Texas A&M University), Herb Sutter (Microsoft) [Chairman, President], and Michael Wong (IBM) [Vice President].