-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal changes to support constexpr allocation in MSVC #1313
Conversation
* Define `_CONSTEXPR20_DYNALLOC` macro to `constexpr` when the compiler defines `__cpp_constexpr_dynamic_alloc` and `inline` otherwise. * Implement and test `ranges::construct_at` and `ranges::destroy_at`, mark them (and `std` flavors) `_CONSTEXPR20_DYNALLOC`. * Implement `ranges::destroy` and `ranges::destroy_n` which share machinery with `ranges::destroy_at` with minimal test coverage. (More to follow.) [This is a dual of internal MSVC-PR-275909.]
Full disclosure: there's really no reason for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blah blah missing test coverage, but this looks great
auto construct_at(_Ty* const _Location, _Types&&... _Args) noexcept(noexcept(::new (const_cast<void*>( | ||
static_cast<const volatile void*>(_Location))) _Ty(_STD forward<_Types>(_Args)...))) // strengthened | ||
_CONSTEXPR20_DYNALLOC auto construct_at(_Ty* const _Location, _Types&&... _Args) noexcept( | ||
noexcept(::new (const_cast<void*>(static_cast<const volatile void*>(_Location))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HM in the uninitialized_meow PR we introduced a voidify Funktion. If it is not too far out we should wait until it is merged or reproduce it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole point of pushing this through before finishing test coverage is to avoid blocking the compiler team. If we get uninit_meow
merged in time, I'll make the voidify
change here. Otherwise, I'll do so in the followup. (Leaving this comment open as a reminder.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MSVC-PR-276291 is internally out for review, containing uninit_meow
, so it's a race 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that mean we can have a look at constexpr container after this is merged (excluding string and vector of course) |
_CONSTEXPR20_DYNALLOC
macro toconstexpr
when the compiler defines__cpp_constexpr_dynamic_alloc
andinline
otherwise.ranges::construct_at
andranges::destroy_at
, mark them (andstd
flavors)_CONSTEXPR20_DYNALLOC
.ranges::destroy
andranges::destroy_n
which share machinery withranges::destroy_at
with minimal test coverage. (More to follow.)[This is a dual of internal MSVC-PR-275909.]
Partially implements #37 and #39.