[cfe-dev] [libcxx] RFC: C++14 and beyond

Marshall Clow mclow.lists at gmail.com
Thu May 2 10:51:13 PDT 2013

On May 2, 2013, at 10:13 AM, Matthieu Monrocq <matthieu.monrocq at gmail.com> wrote:

> On Thu, May 2, 2013 at 3:50 PM, Howard Hinnant <hhinnant at apple.com> wrote:
> libcxx was begun as a C++11 (then called C++0x) library.  It never even tried to adhere to the C++03 specification, though it does endeavor to work in C++03 language mode.
> Now we have a working draft for C++14 and certainly libc++ needs to support C++14.  However not all C++14 changes are 100% API compatible with C++11 (just like there are a few API breakages between C++03 and C++11).  For example John Spicer demonstrated the following example which shows that you can silently impact run time behavior by adding constexpr to a function.
> #if 0
> constexpr
> #endif
> int g(int) { return 1; }
> template <int I> struct A {};
> template <class T> auto f(T*) -> decltype(A<g(T())>())*;  // called if g is constexpr
> template <class T> int f(T);  // called if g is not constexpr
> int
> main()
> {
>     int *p = 0;
>     f(p);
> }
> This indicates that even the post-C++11 additions of constexpr to chrono::time_point and tuple have the potential to break code.
> This isn't an argument for not adding post-C++11 items to libc++.  It is simply an argument that we should provide a way for platforms and clients to choose:
> 1.  What is the default C++ standard libc++ is going to adhere to for a given platform?
> 2.  How do clients override the default?
> And I believe we should create a scalable solution beyond just the choice between C++11 and C++14.  C++17 is just around the corner.  And we should, at least for now, avoid macro names which allude to the numbers 14 and 17 as there is no telling whether the committee will keep its schedule or not (it doesn't have a very good track record).
> I would like to open this topic up for discussion as I'm already aware of two post C++11 contributions that are blocked on this issue.
> Regarding the numbering... at the moment "C++14" are enabled in gcc by using -std=c++1y (and I believe in Clang too), maybe using 1Y for now and changing it to 14 (or 15) once the Standard is finalized would work ?

How do you detect that a compilation was invoked with the "std=c++1y" flag?
The traditional way of doing that is by inspecting the preprocessor define __cplusplus, but the value for that has not been determined for C++14.

tot clang and gcc 4.8 both use "201103" for -std=c++11 and -std=c++1y
[ I expect this will change by the time C++14 is adopted, but that's what it is today. ]

-- Marshall

Marshall Clow     Idio Software   <mailto:mclow.lists at gmail.com>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
        -- Yu Suzuki

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130502/f48f214b/attachment.html>

More information about the cfe-dev mailing list