[libcxx-commits] [libcxx] [libc++] Use _If for conditional_t (PR #96193)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 26 04:27:30 PDT 2024
zmodem wrote:
We've run into compile errors after this. I'm not sure if this is an unintentional effect of this change, or if we're doing something wrong. [The code](https://github.com/abseil/abseil-cpp/blob/9957f27686debcb8891b6b135343d3f7cb6384cd/absl/container/internal/common_policy_traits.h#L116-L120) looks like this:
```
// This overload returns true_type for the trait below.
// The conditional_t is to make the enabler type dependent.
template <class Alloc,
typename = std::enable_if_t<absl::is_trivially_relocatable<
std::conditional_t<false, Alloc, value_type>>::value>>
static std::true_type transfer_impl(Alloc*, slot_type* new_slot,
slot_type* old_slot, Rank1) {
```
And now fails to compile:
```
../../third_party/libc++/src/include/__type_traits/enable_if.h:32:40: error: no type named 'type' in 'std::enable_if<false>'; 'enable_if' cannot be used to disable this declaration
32 | using enable_if_t = typename enable_if<_Bp, _Tp>::type;
| ^~~
../../third_party/abseil-cpp/absl/container/internal/common_policy_traits.h:117:29: note: in instantiation of template type alias 'enable_if_t' requested here
117 | typename = std::enable_if_t<absl::is_trivially_relocatable<
| ^
../../third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h:33:29: note: in instantiation of template class 'absl::container_internal::common_policy_traits<absl::container_internal::FlatHashMapPolicy<sh::SpirvType, sh::SpirvTypeData>>' requested here
33 | struct hash_policy_traits : common_policy_traits<Policy> {
| ^
../../third_party/abseil-cpp/absl/container/internal/raw_hash_set.h:2346:30: note: in instantiation of template class 'absl::container_internal::hash_policy_traits<absl::container_internal::FlatHashMapPolicy<sh::SpirvType, sh::SpirvTypeData>>' requested here
2346 | using init_type = typename PolicyTraits::init_type;
| ^
../../third_party/abseil-cpp/absl/container/internal/raw_hash_map.h:33:29: note: in instantiation of template class 'absl::container_internal::raw_hash_set<absl::container_internal::FlatHashMapPolicy<sh::SpirvType, sh::SpirvTypeData>, sh::SpirvTypeHash, std::equal_to<sh::SpirvType>, std::allocator<std::pair<const sh::SpirvType, sh::SpirvTypeData>>>' requested here
33 | class raw_hash_map : public raw_hash_set<Policy, Hash, Eq, Alloc> {
| ^
../../third_party/abseil-cpp/absl/container/flat_hash_map.h:126:14: note: in instantiation of template class 'absl::container_internal::raw_hash_map<absl::container_internal::FlatHashMapPolicy<sh::SpirvType, sh::SpirvTypeData>, sh::SpirvTypeHash, std::equal_to<sh::SpirvType>, std::allocator<std::pair<const sh::SpirvType, sh::SpirvTypeData>>>' requested here
126 | : public absl::container_internal::raw_hash_map<
| ^
../../third_party/angle/src/compiler/translator/spirv/BuildSPIRV.h:500:61: note: in instantiation of template class 'absl::flat_hash_map<sh::SpirvType, sh::SpirvTypeData, sh::SpirvTypeHash, std::equal_to<sh::SpirvType>>' requested here
500 | angle::HashMap<SpirvType, SpirvTypeData, SpirvTypeHash> mTypeMap;
| ^
```
We can work around it by using `conditional<>::type` instead of `conditional_t<>`, but it seems wrong that they should behave differently.
https://github.com/llvm/llvm-project/pull/96193
More information about the libcxx-commits
mailing list