__cpp_lib library feature test macros

clang implements feature testing macros for language features but I notice that libc++ does not implement the library testing macros. Is this deliberate or would patches to fix this be welcome?

Attached is an initial attempt at implementing Feature-testing recommendations for C++ based on http://libcxx.llvm.org/cxx1y_status.html. No tests are included yet.

Also, about the language feature testing, I notice that they don't take into account features being disabled via -Werror=. It seems like this might matter in cases such as a third party library's headers doing feature testing, but where the local build environment has disabled features for whatever reason. It seems reasonable that a header testing #if __has_extension(__cxx_constexpr__) or #ifdef __cpp_constexpr would use whatever fallback code it's got when the user disables constexpr. Feature testing does take into account features disabled with -fno- arguments.

- Seth

0001-implement-library-feature-test-macros-n4030.patch (8.37 KB)

clang implements feature testing macros for language features but I notice
that libc++ does not implement the library testing macros. Is this
deliberate or would patches to fix this be welcome?

Attached is an initial attempt at implementing
Feature-testing recommendations for C++ based
on http://libcxx.llvm.org/cxx1y_status.html. No tests are included yet.

Also, about the language feature testing, I notice that they don't take
into account features being disabled via -Werror=.

Which, if any, features can we disable via -Werror? I don't think we have a
warning for constexpr, for example - we have a generic warning for all
C++11 features (so you can build a codebase as C++11 without allowing the
codebase to become C++98-incompatible), so arguably all the language
features could be "not available" when built with that warning and -Werror,
but that would change the behavior of your program, which would be
problematic if you wanted to make sure that when you build as C++11 the
project works (because then if you disabled the warning, you'd end up with
different behavior - so your experimental results wouldn't be
representative of the end state you were aiming for)

Hi All,

CC Marshall,

I’ve had some offline discussions with Marshall about adding feature testing macros to libc++ and there was some hesitation about doing it.
Patches (with test cases) are welcome, but I don’t know if we have decided on a direction yet. There is a similar bug report that can be found here: http://llvm.org/bugs/show_bug.cgi?id=18584.

/Eric