Back to 2014-proposals
Title: Generic Programming with Concepts Lite
Proposer: Andrew Sutton
Type: Tutorial
Duration: 90 mins
Description:
In this talk, I will give an overview of the Concepts Lite language extension
for the C++ and present examples of its use in the design and implementation of
real-world generic libraries. Concepts Lite provides the ability for programmers
to directly state constraints on template arguments as part of the template
declaration. These constraints are predicates that determine whether or not a
template argument can be used with that template, and they are checked by the
compiler at the point of use, not unlike an asserted precondition, meaning that
that effectively constrained generic libraries will not suffer from the usual
problems of insane diagnostics. Moreover, libraries written using Concepts Lite
are more readable, maintainable, and elegant.
While Concepts Lite is straightforward and easy to grasp, early experience has
shown that some retraining is required to use the features effectively. Current
techniques used in generic library construction are made practically obsolete by
Concepts Lite. The effective and principled use of Concepts Lite is rooted in
the definition of predicates as logical expressions and their implications.
Advanced language rules and programming idioms like SFINAE, type traits, and
metaprogramming are no longer required to design and implement good libraries.
Examples will be presented from the Origin C++ Libraries, the first large-scale
application of Concepts Lite to generic library construction.
Concepts Lite is a forthcoming ISO Technical Specification (TS) aimed at
publication alongside C++14. Concepts Lite is implemented in a branch of GCC,
which will be made available to the audience for experiments and experience.