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< ...@@ -50,6 +50,11 @@ using SetOrMapValueType = std::conditional_t<
KeyType, KeyType,
MapValueType<KeyType, MappedTypeOrVoid>>; 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 // Used to enable EBO for Hasher, KeyEqual, and Alloc. std::tuple of
// all empty objects is empty in libstdc++ but not libc++. // all empty objects is empty in libstdc++ but not libc++.
template < template <
...@@ -611,18 +616,18 @@ class ValueContainerPolicy : public BasePolicy< ...@@ -611,18 +616,18 @@ class ValueContainerPolicy : public BasePolicy<
} }
template <typename T> template <typename T>
std::enable_if_t<std::is_nothrow_move_constructible<T>::value> std::enable_if_t<IsNothrowMoveAndDestroy<T>::value>
complainUnlessNothrowMove() {} complainUnlessNothrowMoveAndDestroy() {}
template <typename T> template <typename T>
[[deprecated( [[deprecated(
"use F14NodeMap/Set or mark key and mapped type move constructor nothrow")]] std:: "mark {key_type,mapped_type} {move constructor,destructor} noexcept, or use F14Node* if they aren't")]] std::
enable_if_t<!std::is_nothrow_move_constructible<T>::value> enable_if_t<!IsNothrowMoveAndDestroy<T>::value>
complainUnlessNothrowMove() {} complainUnlessNothrowMoveAndDestroy() {}
void moveItemDuringRehash(Item* itemAddr, Item& src) { void moveItemDuringRehash(Item* itemAddr, Item& src) {
complainUnlessNothrowMove<Key>(); complainUnlessNothrowMoveAndDestroy<Key>();
complainUnlessNothrowMove<lift_unit_t<MappedTypeOrVoid>>(); complainUnlessNothrowMoveAndDestroy<lift_unit_t<MappedTypeOrVoid>>();
constructValueAtItem(0, itemAddr, Super::moveValue(src)); constructValueAtItem(0, itemAddr, Super::moveValue(src));
if (destroyItemOnClear()) { if (destroyItemOnClear()) {
...@@ -1255,18 +1260,18 @@ class VectorContainerPolicy : public BasePolicy< ...@@ -1255,18 +1260,18 @@ class VectorContainerPolicy : public BasePolicy<
void destroyItem(Item&) noexcept {} void destroyItem(Item&) noexcept {}
template <typename T> template <typename T>
std::enable_if_t<std::is_nothrow_move_constructible<T>::value> std::enable_if_t<IsNothrowMoveAndDestroy<T>::value>
complainUnlessNothrowMove() {} complainUnlessNothrowMoveAndDestroy() {}
template <typename T> template <typename T>
[[deprecated( [[deprecated(
"use F14NodeMap/Set or mark key and mapped type move constructor nothrow")]] std:: "mark {key_type,mapped_type} {move constructor,destructor} noexcept, or use F14Node* if they aren't")]] std::
enable_if_t<!std::is_nothrow_move_constructible<T>::value> enable_if_t<!IsNothrowMoveAndDestroy<T>::value>
complainUnlessNothrowMove() {} complainUnlessNothrowMoveAndDestroy() {}
void transfer(Alloc& a, Value* src, Value* dst, std::size_t n) { void transfer(Alloc& a, Value* src, Value* dst, std::size_t n) {
complainUnlessNothrowMove<Key>(); complainUnlessNothrowMoveAndDestroy<Key>();
complainUnlessNothrowMove<lift_unit_t<MappedTypeOrVoid>>(); complainUnlessNothrowMoveAndDestroy<lift_unit_t<MappedTypeOrVoid>>();
auto origSrc = src; auto origSrc = src;
if (valueIsTriviallyCopyable()) { 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