Last week, around 15 members of the ISO C++ standards committee met for two days at Google to discuss the concepts proposal and tie down various details. Some syntax has changed, some semantics has changed, but the vast majority of the concepts proposal is exactly the same as it was.
We made the following syntactic changes, all of which have been implemented in the latest development version of ConceptGCC (in Subversion):
– The “where” keyword has been changed to “requires”, e.g.,
template<typename T> requires LessThanComparable<T> const T& min(const T& x, const T& y);
– The && syntax used to separate requirements in a where clause (now a “requires clause” or “requirements clause”) has been replaced with “,”. The requires clause is now just a comma-separate list of requirements, and the list has (optional!) parentheses around it. An example:
template<typename Iter, typename T> requires InputIterator<Iter>, EqualityComparable<Iter::value_type, T> Iter find(Iter first, Iter last, const T& value);
– The use of “where” inside function bodies, which was never supported by ConceptGCC, has been removed.
– “late_check” now comes before “template” in the template header. ConceptGCC already parsed late_check in this way; now, it’s official.
ConceptGCC implements these changes, and warns about the use of the “where” keyword and && syntax. These warnings will remain for a few versions, until existing code can be ported to the new syntax.
There were a few semantic changes, which have not yet made it into GCC:
– It is no longer correct to call an unconstrained template from a constrained one. Use late_check if you need to do this.
– Name lookup in requires clauses will use lexical scoping. This has been the default in ConceptGCC since its creation, but we supported other name lookup approaches. Those are gone. ConceptGCC also includes a warning when a using declaration hides a name in the requires clause (enabled by -Wall or -Wsignature-shadow). See the discussion of name lookup and std::swap for the motivation behind this warning.
– Name lookup of associated types inside template parameters (e.g., Iter::value_type) now works regardless of whether the requirement comes from the template header or from the requires clause. ConceptGCC has had two modes for a while; we’ve removed the only-look-in-inline-requirements mode.
Along with these changes, I’ve managed to fix several bugs in ConceptGCC that were causing build problems on various architectures. The changes themselves are uninteresting; what matters is that the development version of ConceptGCC should build without problems.