'Concepts lite' were already accepted as a TS and (example implementation) merged into GCC main branch, so the follow up question is will any concepts come predefined (like Sortable or Random_access_range)?
Where do I look for such predefined concepts?
Is the list at cppreference.com an acurate and exhaustive list?
Can I use them with the latest GCC trunk build?
Edit 1: Changed C++17 to TS due to concepts not being accepted into C++17.
There are no concepts defined in the Concepts TS (source: I wrote the Concepts TS).
It is neither an oversight nor mistake... The goal was to ship a pure language extension in the TS, allowing developers time to experiment with the new features before committing (an incredible amount of) time defining the concepts needed for the Standard Library.
The Ranges TS will define the concepts needed for the Standard Library.
GCC may ship with some concepts, but I have not heard of any concrete plans to do so. I have a library that defines many of the concepts (but not all) that appear in the Ranges TS here: https://github.com/asutton/origin, but I'm still working on a usable release and appropriate documentation. And it only compiles against GCC from trunk. I'm hoping for adequate documentation by next week.
'Concepts lite' were already accepted for C++17
No, it isn't. It's a separate TS.
will any concepts come predefined?
Not by the Concepts TS, which is limited to the language feature. The current Ranges TS working draft does define a number of concepts.
Related
Let me give a concrete example to make it more clear what I exactly mean.
I have two drafts of C++ standard: N4296 that is quite old now and more recent revision N4750. There are some subsections that I am interested in, e.g. [unord.hash]. Version N4296 requires from std::hash to provide two nested types argument_type and result_type, but this requirement no longer present in N4750.
How can I find the revision, where this requirement was removed and the motivation for it?
Another source you can use is cppreference. They do a very good job in showing what is different in the different version of the standard. For instance, the std::hash page lists that argument_type and result_type are deprecated in C++17 and removed in C++20. With that information you at least know that the remove happened in a version of the standard between C++17 and C++20, which is lot less versions to look through.
Additionally, in at least some sections, if there was a defect report there will also be a link to that defect report on the page.
You'll still have to do some hunting, but hopefully this will narrow it down for you.
This can actually be kind of hard.
Individual revisions
First, there's the list of closed core language issues (and the equivalent page for library issues), which gives you a paper reference and some date information.
There's the working group's mailings.
There's the standard's source whose history can be examined using Git tools and their friends. The commit log in theory should be useful — though I recommend noting down the name (e.g. a word like "N3690") of the Final Draft for each standard so that you can recognise it in the tag list.
This is your best bet if you're literally looking for the specific revision where a change was introduced.
Between standards
When trying to determine in which standard the change was introduced, personally I tend to just open up individual standard documents and do my own visual bisection. This works well if you know where the feature's wording is located in the standard, and if the wording is mostly compartmentalised in one place, though it can still be time consuming.
For motivations you'll be looking for the original proposal paper. If you manage to find the draft revision where the change was made, hopefully someone will have cross-referenced the name/ID of the proposal.
I also find that Google gives some good results when searching for this if you already have a vague idea of its contents: e.g. "C++ if declaration definition while for consistent proposal".
And, if you don't mind non-authoritative sources (which should nonetheless be reliable), there are usually Stack Overflow answers that track changes between C++ standards, with links to the relevant papers. For example, this answer to "What are the new features in C++17?", which references the changes to std::hash that you mention.
As highlighted by a recent answer to this question, gcc now supports concepts-lite in builds from its svn trunk.
The same question links to the most recent TS, N4377. Edit - answer has a newer TS.
A helpful paper can be found labelled N3580 - this is from 2013, and the authors are Andrew Sutton, Bjarne Stroustrup and Gabriel Dos Reis.
A list of tweaks to N4377 can be found labelled N4434. This gives 3 suggested changes to the N4377 paper and lists as its reply point Walter E. Brown.
These papers/Technical Specifications are similar, but have various small changes in each case.
Is there some simple way to discover what gcc currently implements? Or indeed, plans to implement?
As a side question: Is ConceptClang or some similarly named project related to the c++1z concepts? A mailing list post from May 2015 collected some thoughts, in particular that:
Larisse may have some work done for the concepts ts, in addition to
her C++0x efforts.
No further reply was made to that thread.
It's my understanding that the GCC maintainers plan to implement Concepts as specified in the final TS that is soon to be published: N4549 C++ Extensions for Concepts. Most of that specification is implemented in GCC, with the notable exception of "generalized auto deduction" which is necessary to compile syntax like std::pair<auto, auto> foo = std::make_pair(x, y);. The implementation is still very rough - a quick search for open bugs with "[concepts]" in the title has 38 hits, so exactly what is implemented and what works well changes from week to week.
Is ConceptClang or some similarly named project related to the c++1z concepts?
ConceptClang is (was?) an implementation of C++0x concepts which I believe has been dead for some time now. There are a few people who have started looking at implementing the Concepts TS in clang in the last several months, they've only submitted a handful of patches to recognize the concept keyword and parse the syntax of concept function and variable declarations.
I am working on a class project which uses C++ concepts. Where can I find an STL implementation that supports has constraints from the concepts draft TS, such as Equality_comparable or Sortable?
Thanks for your help!
Here's what I tried so far:
I've successfully compiled the c++-concepts branch from GCC's SVN, which appears to be maintained (last updated yesterday by Andrew Sutton). However, the libstdc++ that comes with this branch has not been updated for concepts.
I also tried Concepts-Lite (gcc-clite), which promises:
The standard library shipping with this compiler includes the constraints found in the paper "A Concept Design for the STL", which can be accessed by including the <type_traits> header file.
However, libstdc++ in the GCC code downloaded from that page also does not have concepts. In particular, the type_traits header appears to be unchanged from the GCC revision it was forked from.
Have a look at Andrew Sutton's Origin library on github. If you follow the origin/core directory you can find the basic concepts. He has some graph, math, and some container stuff stuff too from the look of it.
I have to admit that I'm in the middle of exploring this myself so I have no intelligent report yet.
Only downside: the most recent check-ins are a couple of months or more ago. I guess we'll see.
There is lots of sweet stuff in TR2. Is that going to be in C++17?
I understand that TR1 was completed in 2005 and had to wait until C++11 to be standardized.
But I also understand that TR2 is already complete?
My link to C++17 doesn't mention anything about TR2, but I am hoping...
Maybe.
The point of TR (and now technical specifications) is to allow something to mature independent of the standard iteration process. They can publish a TS, see how it works, see if there are any problems in the implementation and/or use of the feature, and if everything works they can then "fold" it into the full standard.
Each TS is considered on its own merits to see if it will be folded into the next standard.
See http://isocpp.org/std/status (thanks #BenjaminLindley) for current status of the Technical Specification working groups.
Any of them, if completed well prior to 2017, could be folded into the standard. It is unlikely they all will be.
A goal is that we can get the std::experimental features to play with (and use if we are willing to accept the ground shifting under our feet) earlier, while having the features once added to std with fewer regrets and specification changes after that point. There are probably also massive organizational overhead advantages to decoupling the main line standard from each of these side projects and allowing them to evolve independently.
The purpose of a Technical Report, or Technical Specification as they are now, is to gain implementation experience and feedback from implementors and users, to better assess the suitability of features for standardization. One would need a crystal ball to know if a particular TS will be included in a future standard, and which future standard that might be.
Version 1 of the Library Fundamentals TS appears to have passed its final ballot at the November 2014 committee meeting, and version 2 is currently being drafted to incorporate feedback and new proposals. This means it is getting closer to being something which implementors and industry users are happy with, and version 1 is now an immutable specification which implementors can choose to conform to. It is still more than possible for later versions, and later standards, to change in ways which would be incompatible with version 1.
Here's a list (from your wikipedia link) of the features of TR2 - and my comments:
Threads - Included in C++11
The Asio C++ library - this is being considered for a future C++ standard
Signals/Slots - no action at this time (that I know of)
Filesystem Library - FileSystem Technical Specification
Boost Any Library - Part of the Library Fundamentals Technical Specification
Lexical Conversion Library - no action at this time (that I know of)
New String Algorithms - no action at this time (that I know of)
Toward a More Complete Taxonomy of Algebraic Properties for Numeric Libraries in TR2 - no action at this time (that I know of)
Adding heterogeneous comparison lookup to associative containers for TR2 - * Included in C++14*
As the title says, there's something called Concepts Lite
(Template Constraints) and Concept Design for the STL. Can anybody explain some fundamental differences between these?
The first introduces changes to the C++ language (core) to have facilities for expressing restrictions on templates. Providing sensible checks, good error messages to users and simple tools to template writers.
It will be developed as Technical Specification (TS) and expected by by mid 2014, about same time C++14. Compiler writers seem enthusiastic to ship it soon too.
The second is about library: current standard lib cna't use constraints that are not yet part of the standard for obvious reasons. But once that part is bose, the templates can and will be improved with more native expression of requirements. I.e currently it's only written in the text that template argument must be default-constructible or assignable. So if you use C++03 and std::vector<std::auto_ptr<int> > it's just UB. But with conceptized version such problems will be diagnosed at compile.