Commit 6123dc9f authored by Nick Terrell's avatar Nick Terrell Committed by Facebook GitHub Bot

Explicitly require is_nothrow_destructible in Vector and Value tables

Summary:
The current implementation of `std::is_nothrow_move_constructible` in libstdc++ implies `std::is_nothrow_destructible`. However, this doesn't seem to be required by the standard, see the notes section of https://en.cppreference.com/w/cpp/types/is_constructible.

Since we know that all Vector and Value sets/maps already satisfy this requirement, let's codify it explicitly.

Reviewed By: nbronson

Differential Revision: D20604544

fbshipit-source-id: bae1e8442585cedb062308b6332bd018cccca2f4
parent 8fcf46ad
......@@ -50,6 +50,11 @@ using SetOrMapValueType = std::conditional_t<
KeyType,
MapValueType<KeyType, MappedTypeOrVoid>>;
template <typename T>
using IsNothrowMoveAndDestroy = Conjunction<
std::is_nothrow_move_constructible<T>,
std::is_nothrow_destructible<T>>;
// Used to enable EBO for Hasher, KeyEqual, and Alloc. std::tuple of
// all empty objects is empty in libstdc++ but not libc++.
template <
......@@ -611,18 +616,18 @@ class ValueContainerPolicy : public BasePolicy<
}
template <typename T>
std::enable_if_t<std::is_nothrow_move_constructible<T>::value>
complainUnlessNothrowMove() {}
std::enable_if_t<IsNothrowMoveAndDestroy<T>::value>
complainUnlessNothrowMoveAndDestroy() {}
template <typename T>
[[deprecated(
"use F14NodeMap/Set or mark key and mapped type move constructor nothrow")]] std::
enable_if_t<!std::is_nothrow_move_constructible<T>::value>
complainUnlessNothrowMove() {}
"mark {key_type,mapped_type} {move constructor,destructor} noexcept, or use F14Node* if they aren't")]] std::
enable_if_t<!IsNothrowMoveAndDestroy<T>::value>
complainUnlessNothrowMoveAndDestroy() {}
void moveItemDuringRehash(Item* itemAddr, Item& src) {
complainUnlessNothrowMove<Key>();
complainUnlessNothrowMove<lift_unit_t<MappedTypeOrVoid>>();
complainUnlessNothrowMoveAndDestroy<Key>();
complainUnlessNothrowMoveAndDestroy<lift_unit_t<MappedTypeOrVoid>>();
constructValueAtItem(0, itemAddr, Super::moveValue(src));
if (destroyItemOnClear()) {
......@@ -1255,18 +1260,18 @@ class VectorContainerPolicy : public BasePolicy<
void destroyItem(Item&) noexcept {}
template <typename T>
std::enable_if_t<std::is_nothrow_move_constructible<T>::value>
complainUnlessNothrowMove() {}
std::enable_if_t<IsNothrowMoveAndDestroy<T>::value>
complainUnlessNothrowMoveAndDestroy() {}
template <typename T>
[[deprecated(
"use F14NodeMap/Set or mark key and mapped type move constructor nothrow")]] std::
enable_if_t<!std::is_nothrow_move_constructible<T>::value>
complainUnlessNothrowMove() {}
"mark {key_type,mapped_type} {move constructor,destructor} noexcept, or use F14Node* if they aren't")]] std::
enable_if_t<!IsNothrowMoveAndDestroy<T>::value>
complainUnlessNothrowMoveAndDestroy() {}
void transfer(Alloc& a, Value* src, Value* dst, std::size_t n) {
complainUnlessNothrowMove<Key>();
complainUnlessNothrowMove<lift_unit_t<MappedTypeOrVoid>>();
complainUnlessNothrowMoveAndDestroy<Key>();
complainUnlessNothrowMoveAndDestroy<lift_unit_t<MappedTypeOrVoid>>();
auto origSrc = src;
if (valueIsTriviallyCopyable()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment