Concept Cpp

ConceptCpp (ConceptC++)

ConceptC++ is an extension to the C++ Programming Language that introduces first-class support for GenericProgramming. It is the first attempt to introduce complete support for GenericProgramming into a mainstream programming language. ConceptC++ is a strong candidate for inclusion into the upcoming ANSI/ISO C++ Standard, dubbed C++0x. The OpenSystemsLaboratory? at IndianaUniversity? is developing a prototype compiler for ConceptC++, ConceptGcc.

See also TheCppStandardsCommittee ConceptIntersection CppAndConcepts CeePlusPlusEleven

NOTE: Concepts were dropped from the CeePlusPlusEleven standard.

Pardon my confusion, I thought the templates in C++ were generic programming. How are CppTemplates? incomplete? How much more generic does ConceptCpp make them?

There is some discussion of the need for more than just templates on the pages here named GenericProgramming and SetsOfRequirements. The problem with C++ templates is that there is no type checking associated with the use of the templates. The new proposals enable checking to be done at compile time that the type being passed will supply what is needed for proper execution. There is a lot of information on the page referenced above, including a link to a talk describing the problem and what is proposed. A link to the talk is provided below. -- JohnFletcher

Concepts: Extending the C++ Template System for Generic Programming

Example Code

 #include <list>
 #include <algorithm>
 using namespace std;

void f() { list<int> l; sort(l.begin(), l.end()); }
This does not compile as a list<int> cannot be sorted. The concepts compiler ConceptGcc gives the following error text:
 features.cpp: In function 'void f()':
 features.cpp:13: error: no matching function for call to 'sort(std::_List_iterator<int>, std::_List_iterator<int>)'
 note: candidates are: void std::sort(_Iter, _Iter) [with _Iter = std::_List_iterator<int>] <where clause>
 features.cpp:13: note:   no concept map for requirement 'std::MutableRandomAccessIterator<std::_List_iterator<int> >'

This works because the concepts have been built into the StandardTemplateLibrary implementation which comes with the ConceptGcc compiler. There is also syntax for users to define their own concepts.

For another example see FunctoidsInCppWithConceptCpp.

2011 ConceptGcc is no longer being developed. There is a version of Clang (CeeLanguageFamilyFrontEnd) which includes concepts.

CategoryCpp CategoryCppTemplates CategoryConcepts

EditText of this page (last edited September 28, 2014) or FindPage with title or text search