[libcxx-commits] [PATCH] D55840: P0722R3: Implement library support for destroying delete

Jonathan Wakely via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 13 14:27:32 PST 2019


jwakely added a comment.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89345#c3 for what I've done in libstdc++

tl;dr the type and variable depend on C++2a, the `__cpp_lib` macro depends on the type being defined **and** the compiler defining the impl macro to say it will recognise the type.



================
Comment at: include/new:169
+
+struct destroying_delete_t {
+  explicit destroying_delete_t() = default;
----------------
ldionne wrote:
> EricWF wrote:
> > mclow.lists wrote:
> > > ckennelly wrote:
> > > > ldionne wrote:
> > > > > Please guard with > C++17. We should not enable features in older standards unless we have a compelling reason to.
> > > > If there's compiler support (we're checking _impl), would it be reasonable to provide it with C++17 as well?
> > > Not reasonable, no.
> > > I did this one, for something that I thought was a slam-dunk (`string_view` in pre-c++17) and it has been nothing but a series of small annoyances.
> > > 
> > This is a separate question from `std::string_view`. This is a core-language feature that needs library support. The compiler decides whether this feature is on or off.
> > 
> > Like aligned allocation and sized delete, the library should provide `destroying_delete_t` whenever the compiler defines its language feature test macro. Otherwise, Clang can't do its job. This approach allows users to opt-into important new language features as an extension, or to opt-out of them when availability is a concern (this is particularly important for allocation/deallocation functions).
> > 
> > We should enable the typedef when either `_LIBCPP_STD_VER > 17` or `defined(__cpp_impl_destroying_delete)`. The latter macro signify that Clang needs us to provide the type because *clang* has chosen to provide this language feature as an extension.
> I agree, this should be `#if _LIBCPP_STD_VER > 17 || defined(__cpp_impl_destroying_delete)`.
That will break for C++98 mode, because `constexpr` (and defaulted special members and inline variables) gives an error in C++98. That's the problem I was asked to fix in libstdc++, to be compatible with Clang.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55840/new/

https://reviews.llvm.org/D55840





More information about the libcxx-commits mailing list