[PATCH] [libc++] In C++11 GNU extension mode, start emulating libstdc++'s use of constexpr.
Richard Smith
richard at metafoo.co.uk
Tue Nov 26 15:22:59 PST 2013
I've done no detailed review of the guts of the patch, but I have one high-level question: do we actually want to support a GNU-compatibility mode here, or do we instead want to provide our own extra-`constexpr` extension (in which we intend to mark at least the same set of functions as libstdc++ does)?
I think the latter makes a lot more sense. I also see no reason to restrict this to things that are already `constexpr` in c++14. So I'm thinking of something like:
#if defined(_LIBCPP_CONSTEXPR_EXTENSIONS) && __cplusplus >= 201103L
#define _LIBCPP_CONSTEXPR_AS_EXTENSION constexpr
#else
#define _LIBCPP_CONSTEXPR_AS_EXTENSION
#endif
... then ...
_LIBCPP_CONSTEXPR_AFTER_CXX11
void f() {...} // constexpr in c++14 mode only
_LIBCPP_CONSTEXPR_AS_EXTENSION
int g(); // constexpr in c++11 and c++14 in extensions mode, otherwise not
_LIBCPP_CONSTEXPR_AFTER_CXX11
_LIBCPP_CONSTEXPR_AS_EXTENSION
int h(); // constexpr in c++14, constexpr in c++11 in extensions mode
http://llvm-reviews.chandlerc.com/D2276
More information about the cfe-commits
mailing list