Skip to content

Commit 9327b2a

Browse files
Quuxplusonefacebook-github-bot
authored andcommitted
Traits.h: Use std::is_trivially_relocatable if P1144 is available (#2216)
Summary: Well, llvm/llvm-project#84621 isn't going anywhere in Clang, therefore #2159 will presumably never be mergeable (in the foreseeable future, anyway). So here's an alternative approach, for your consideration: If [P1144's feature-test macro](https://open-std.org/jtc1/sc22/wg21/docs/papers/2024/p1144r10.html#wording) is set, then use `std::is_trivially_relocatable<T>` in place of `std::is_trivially_copyable<T>`. This will produce improved codegen for e.g. `fbvector<std::vector<int>>::erase`, when compiled on a compiler supporting P1144 semantics. https://godbolt.org/z/s6sa313h3 Compare https://github.com/charles-salvia/std_error/blob/3abc272/all_in_one.hpp#L180-L196 Pull Request resolved: #2216 Reviewed By: Gownta Differential Revision: D58147899 Pulled By: Orvid fbshipit-source-id: 671ed21eeb6080f583e6966e776d243c99c9c17f
1 parent b7d52f6 commit 9327b2a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

folly/Traits.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,13 @@ struct IsRelocatable
622622
!require_sizeof<T> ||
623623
is_detected_v<traits_detail::detect_IsRelocatable, T>,
624624
traits_detail::has_true_IsRelocatable<T>,
625-
std::is_trivially_copyable<T>>::type {};
625+
#if defined(__cpp_lib_is_trivially_relocatable) // P1144
626+
std::is_trivially_relocatable<T>
627+
#else
628+
std::is_trivially_copyable<T>
629+
#endif
630+
>::type {
631+
};
626632

627633
template <class T>
628634
struct IsZeroInitializable

0 commit comments

Comments
 (0)