The Future of Generic Programming—How to design good concepts and use them well—Stroustrup

Save to:
Instapaper Pocket Readability

This new paper by Bjarne Stroustrup has been brewing over the holidays, and is now ready for release as a prepublication draft:

Concepts: The Future of Generic Programming
or, How to design good concepts and use them well

by Bjarne Stroustrup

From the draft paper:

Conclusions

Concepts complete C++ templates as originally envisioned. I don’t see them as an extension but as a completion.

Concepts are quite simple to use and define. They are surprisingly helpful in improving the quality of generic code, but their principles – and not just their language-technical details – need to be understood for effective use. In that, concepts are similar to other fundamental constructs, such as functions. Compared to unconstrained templates, there are no run-time overheads incurred by using concepts.

Concepts are carefully designed to fit into C++ and to follow C++’s design principles:

  • Provide good interfaces
  • Look for semantic coherence
  • Don’t force the user to do what a machine does better
  • Keep simple things simple
  • Zero-overhead

Don’t confuse familiarity and simplicity. Don’t confuse verbosity with “easy to understand.” Try concepts! They will dramatically improve your generic programming and make the current workarounds (e.g., traits classes) and low-level techniques (e.g., enable_if – based overloading) feel like error-prone and tedious assembly programming.

Add a Comment

You must sign in or register to add a comment.

Comments (1)

0 0

Helmut Zeisel (Oesterreich) said on Feb 3, 2017 01:32 AM:

The end of section 8.6 says: "My initial template design did not have the prefix template<typename T> syntax."

How did the initial template syntax look like?