Page MenuHomePhabricator

[libc++] Make std::allocator_arg and friends conforming in C++17
AcceptedPublic

Authored by ldionne on Wed, Mar 8, 8:04 AM.

Details

Reviewers
Mordante
Group Reviewers
Restricted Project
Summary

This patch makes global tag variables like std::allocator_arg
conform to C++17 by defining them as inline constexpr variables.
This is possible without creating an ODR violation now that we don't
define strong definitions of those variables in the shared library
anymore.

Diff Detail

Event Timeline

ldionne created this revision.Wed, Mar 8, 8:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptWed, Mar 8, 8:04 AM
ldionne requested review of this revision.Wed, Mar 8, 8:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptWed, Mar 8, 8:04 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Mordante accepted this revision.Wed, Mar 8, 10:59 AM
Mordante added a subscriber: Mordante.

Thanks for working on this! This makes helps to enable modules in libc++.

LGTM, but I really would like to use a helper macro over #ifdefs.

libcxx/include/__functional/bind.h
67

I thought you had a marco _LIBCPP_INLINE_CONSTEXPR_VAR in a different patch, that could be sued here too.

This revision is now accepted and ready to land.Wed, Mar 8, 10:59 AM

LGTM, but I really would like to use a helper macro over #ifdefs.

Another option would be to just always mark them inline. Both clang and GCC support this as an extension.

LGTM, but I really would like to use a helper macro over #ifdefs.

Another option would be to just always mark them inline. Both clang and GCC support this as an extension.

Really? I wasn't aware of that. In that case +1 for that solution.

LGTM, but I really would like to use a helper macro over #ifdefs.

Another option would be to just always mark them inline. Both clang and GCC support this as an extension.

Really? I wasn't aware of that. In that case +1 for that solution.

I think the main problem with that approach is that it will be hard to only use extensions in the libc++ headers and not in the tests. We could probably add some magic into _LIBCPP_BEGIN_NAMESPACE_STD and _LIBCPP_END_NAMESPACE_STD, since we have 99% of our code in there, but Clang and GCC support different extension in some cases, making it potentially quite annoying to find out which ones are supported.