Back to proposals-2013
Title: Concepts Lite-Constraining Templates with Predicates
Proposer: andrew_sutton
Type: Tutorial
Duration: 45 minutes
Description:
In this talk I introduce a new language feature being proposed for C++14:
template constraints (a.k.a., concepts lite). A constraint is a predicate that
determines whether or not a template argument can be used with a template. Using
constraints, we can improve the declaration of templates by directly stating
their requirements, and we can also overload functions on constraints.
Constraints also allow type errors to be caught at the point use, meaning that
scrolling through dense stacks of compiler errors will soon be a thing of the
past.
As a language feature, template constraints are minimal and uncomplicated,
emphasizing correctness of template use rather than the correctness of template
definitions. This means that they can be adopted incrementally and easily into
an existing code base.
The talk will cover examples of how to use constraints with generic algorithms
and data structures, member functions and constructors, overloading, class
template specialization, and the definition of constraints themselves. I will
also discuss my experiences using constraints in day-to-day programming,
including some good ideas and some not-so-good.
An experimental compiler based on GCC-4.8 will also be made available to the
audience.
Asti: interesting and also just 45 min. yes
Roger: Yes