Poll: Portland attendees and subgroups
If you are planning to attend the Portland meeting, please fill out this brief poll to help us allocate rooms and plan for the week. Thanks!
March 23-28, London, UK
By Herb Sutter | Oct 7, 2012 02:44 PM | Tags: None
If you are planning to attend the Portland meeting, please fill out this brief poll to help us allocate rooms and plan for the week. Thanks!
By Blog Staff | Oct 2, 2012 02:07 PM | Tags: advanced
Fresh off the press at C++ Next:
Using strings in C++ template metaprograms
by Abel Sinkovics and Dave Abrahams
Of all the reasons to love metaprogramming, probably the most compelling is that it lets us embed “little languages” in our programs... Instead of C++ expressions, of course, strings could be used to represent the DSL code snippet in the embedding C++ code. In fact, that’s an approach used by many “traditional” libraries:
auto all_caps = std::regex("[A-Z]+"); // OKThe only problem is, the contents of that string are only known at runtime, which means the language has to be interpreted at runtime, and we lose the benefit of being able to translate the structure into compiled code. The “delayed evaluation” has been delayed too long.
If, however, these strings could be parsed at compile-time, the resulting programs could have optimal performance again...
By Blog Staff | Sep 30, 2012 01:33 PM | Tags: intermediate basics
Why make your classes final?
I was often wondering why anyone would want to prohibit inheritance from one’s class in C++. Recently I came across one good example where this is useful...
By Blog Staff | Sep 26, 2012 03:53 AM | Tags: experimental advanced
Unifying Generic Functions and Function Objects
I just got finished collaborating on a proposal with Faisal Vali and Herb Sutter to include generic lambdas and pythy functions in the core language. After the upcoming Portland committee meeting, we should have a good sense of how much appetite there is on the committee for including these features in C++.
While we were writing that paper, we got some of our most helpful comments and insights from Mathias Gaunard. It was a pivotal moment when Mathias reminded us that we could create operator overload sets explicitly with inheritance and using declarations, and then used it to demonstrate "overloaded lambda expressions..."
By Herb Sutter | Sep 26, 2012 12:28 AM | Tags: None
The pre-Portland mailing is now available. It contains over 70 papers, most of them technical proposals to be considered at the upcoming October 15-19 ISO C++ meeting in Portland, along with some minutes and other administrative papers.
By Blog Staff | Sep 20, 2012 02:17 PM | Tags: intermediate
Hot of the press at Dr. Dobb's:
Padding and Rearranging Structure Members
By Dan Saks
... Multibyte objects often have an alignment ... a "requirement that objects of a particular type be located on storage boundaries with addresses that are particular multiples of a byte address". The Standard leaves it up to each target processor to specify its alignment requirements. That is, a processor might require that a 4-byte integer or pointer referenced as a single object be word aligned — at an address that's a multiple of four. A processor also might require that an 8-byte floating-point number be word aligned, or maybe even double-word aligned — at an address that's a multiple of eight.
According to the C Standard, a program that attempts to access an improperly aligned object produces undefined behavior. This means that the program is in error, but the exact consequences of that error are platform-dependent. With many processors, an instruction that attempts to access improperly aligned data issues a trap. With other processors, an instruction that accesses misaligned data executes properly but uses up more cycles to fetch the data than if the data were properly aligned...
By Blog Staff | Sep 19, 2012 02:55 PM | Tags: None
Casablanca is a Microsoft incubation effort to support cloud-based client-server communication in native code using a modern asynchronous C++ API design. Think of it as Node.js, but using C++ -- from simple services, to JSON and REST, to Azure storage and deployment, and more.
Casablanca gives you the power to use existing native C++ libraries and code to do awesome things on the cloud server. In this talk from TechEd Australia, John Azariah and Mahesh Krishnan show how it's done.
By Blog Staff | Sep 18, 2012 01:44 PM | Tags: intermediate basics
The second panel from C++ and Beyond 2012 is now available on Channel 9:
Alexandrescu, Meyers and Sutter - Ask Us Anything
Here is the "Ask Us Anything" panel from C++ and Beyond 2012.
Andrei Alexandrescu, Scott Meyers and Herb Sutter take questions from attendees. As expected, great questions and answers...
By Blog Staff | Sep 18, 2012 10:45 AM | Tags: None
Reminder: Bjarne Stroustrup is appearing live tomorrow in Austin, TX.
C++11 Style: A Touch of Class (Bjarne Stroustrup)
September 19, Austin, TX, USA
What principles, techniques, and idioms can we exploit to make it easier to produce quality code? This presentation reflects my thoughts on what “Modern C++” should mean in the 2010s: a language for programming based on light-weight abstraction with a direct and efficient mapping to hardware, suitable for infrastructure code. I will make an argument for type-rich interfaces, compact data structures, integrated resource management and error handling, and highly-structured algorithmic code. I will illustrate my ideas and motivate my guidelines with a few idiomatic code examples. I will use C++11 freely. Examples include auto, general constant expressions, uniform initialization, type aliases, type safe threading, and user-defined literals. C++ features are only just starting to appear in production compilers, so some of my suggestions have the nature of conjecture. However, developing a “modern style” is essential if we don’t want to maintain newly-written 1970s and 1980s style code in 2020.
By Blog Staff | Sep 17, 2012 09:01 AM | Tags: advanced
Via C++ Next, hat tip to Dave Abrahams:
Chris Kohlhoff’s ASIO library contains an extraordinary little header, not in the public interface, but in the examples directory, that implements what he calls “Stackless Coroutines” (very similar to Python’s Simple Generators if you’re familiar with those). He does it completely portably, with just a few macros, and considering that there are zero lines of platform-specific code, they work amazingly well.
Dave cites this article that describes how to use the coroutines:
A potted guide to stackless coroutines
Keen-eyed Asio users may have noticed that Boost 1.42 includes a new example, HTTP Server 4, that shows how to use stackless coroutines in conjunction with asynchronous operations. This follows on from the coroutines I explored in the previous three posts, but with a few improvements. In particular:
- the pesky entry pseudo-keyword is gone; and
- a new fork pseudo-keyword has been added.
The result bears a passing resemblance to C#'s yield and friends. This post aims to document my stackless coroutine API, but before launching into a long and wordy explanation, here's a little picture to liven things up...