ConceptClang


Introduction

ConceptClang is an implementation of C++ concepts, developed as an extension of the Clang compiler -- an LLVM frontend for the C family of programing languages. It presents an infrastucture for implementing concepts, in a manner independent of and extensible to alternative design-specific details. Thus, it aims at providing a modular and generic interface for implementing various designs for concepts.

Its compilation model is inspired from influential resources on generic programming with concepts and designing concepts for C++, notably:

We have provided a documentation of the interface and two of its instantiations, implementing the Palo Alto and pre-Frankfurt designs.
The implementation is still being completed and should be available soon.

Supported Features

Most necessary features are covered and include:
  • constrained template parameters,
  • implicit and explicit concepts,
  • concepts overloading,
  • concepts-based overloading,
  • use-patterns,
  • associated types, functions, and requirements,
  • concepts refinements,
  • explicit refinements -- parsing only,
  • late-check -- parsing only, and
  • concept id as qualifiers.
For the sake of genericity and ease of implementation, we found a few of those features to not need to be implemented exactly as according to their associated standard. We will gradually document those features as necessary.

Features Not Yet Supported

The following might eventually be implemented:
  • Support/builtin concepts,
  • Using declarations for concept ids,
  • concept-instance-alias definitions,
  • forward declarations of concepts definitions and models,
  • Semantic analysis for axiom declarations.

Compiler Flags

Compiler flag options are also supported to navigate through varying combinations of the features across different designs:
One can choose between different design modes with the compiler flag --with-concepts=. (Note that C++11 features should be enabled.)
Examples:
clang++ -std=c++0x --with-concepts=paloalto example.cpp -o example

Once a mode is selected, one can select different design options with the compiler flag -concepts-option=.
Examples:
clang++ -std=c++0x --with-concepts=paloalto -concepts-option=lightweight example.cpp -o example
clang++ -std=c++0x --with-concepts=paloalto -concepts-option=lightweight
                  -concepts-option=constraints-specs-ord-2 example.cpp -o example

  • Concepts design modes:
    paloalto
    - selects the Palo Alto design
    prefrankfurt
    - selects the pre-Frankfurt design
    default
    - selects the ConceptClang default, currently =paloalto
    none
    - disables the concepts features

  • Concepts design options:
    implicit
    - disables support for explicit concepts
    explicit
    - disables support for implicit concepts
    explicit-refinement
    - adds support for explicit refinements. [Only the parsing supported for now.]
    latecheck
    - adds support for late check blocks.
    constraints-specs-ord-N
    - The priority setting that overload resolution should follow when ordering template specializations. In other words, which of these two partial ordering should take priority and how: the constraints on the templates or the specializations of templates?
    N = 0
    specifies comparing the constraints first [ConceptClang Default],
    N = 1
    specifies comparing the constraints after comparing the specializations, but before comparing the qualifiers.
    N = 2
    specifies comparing the constraints after the comparing the qualifiers. [N2914 option.]
    Any other value for N
    is not supported.
    lightweight
    - selects the option of lightweight concepts. [Specific to the Palo Alto design.]
    heavyweight
    - selects the option of heavyweight concepts. [Specific to the Palo Alto design. Not yet supported.]

We are open to additional necessary options. So please feel free to just let us know.

Talks and Publications

Additional Resources

Additional Resources can be found at the ConceptCPP site.

The Compilation Model

The ConceptClang infrastructure is centered around the following main constituants of
generic programming with concepts, each by some varying degree of support depending on the selected design for concepts:
  • concept definitions,
  • concept model specifications,
    • some of which can be templated,
  • constrained template definitions,
  • constrained template specializations' checking,
    • which consists of constraints satisfaction after normal type checking, and
  • constrained template instantiations.

In addition to the above, we consider an extension of function overloading: concepts-based overloading.
This deals with maintainning support for adhoc-polymorphism in the presence of concepts.

  1. Implementation Considerations
  2. Implementation Structure


Implementation Status

We have provided a brief description of the interface and two of its instantiations. An API Documentation is also available.

Download

An initial prototype for ConceptClang was deployed in 2011 and is available for download. That prototype was based on the pre-Frankfurt standard.

Since then, we have updated the implementation by a great deal, extending the set of supported features, as well as improving our modular and generic structure, with respect to the most recent Palo Alto design and other design alternatives.

The implementation is currently undergoing testing and hopefully final fixes, in preparation for some peer review. Please stay tuned for ongoing progress reports. The implementation will be deployed as soon as we have a satisfactory set of tests running.

If you absolutely would like to live on the edge, checkout a copy of the repository (subject to change) at:
git pull git://github.iu.edu/lvoufo/ConceptClang.git
[Note that, since the implementation has undergone a heavy restructuring since the previous deployment, and we have yet to complete our testing phase, surprises are to be expected... Many thanks for your patience!]

Documentation


Future

Depending on time and demands, we will explore the following additional features and extensions, in no particular order:

References


Bugs and Comments

Please submit all bug reports or comments to Larisse, with "[ConceptClang-Bug]" in the subject line:
email: lvoufo at osl dot iu dot edu.