mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Update LLVM libraries to 14.0.6 (#4350)
The main noticeable change is the SmallString conversion operator to std::string is now explicit instead of implicit.
This commit is contained in:
@@ -634,4 +634,47 @@ TEST(DenseMapCustomTest, OpaquePointerKey) {
|
||||
EXPECT_EQ(Map.find(K2), Map.end());
|
||||
EXPECT_EQ(Map.find(K3), Map.end());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
struct A {
|
||||
A(int value) : value(value) {}
|
||||
int value;
|
||||
};
|
||||
struct B : public A {
|
||||
using A::A;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace wpi {
|
||||
template <typename T>
|
||||
struct DenseMapInfo<T, std::enable_if_t<std::is_base_of<A, T>::value>> {
|
||||
static inline T getEmptyKey() { return {static_cast<int>(~0)}; }
|
||||
static inline T getTombstoneKey() { return {static_cast<int>(~0U - 1)}; }
|
||||
static unsigned getHashValue(const T &Val) { return Val.value; }
|
||||
static bool isEqual(const T &LHS, const T &RHS) {
|
||||
return LHS.value == RHS.value;
|
||||
}
|
||||
};
|
||||
} // namespace wpi
|
||||
|
||||
namespace {
|
||||
TEST(DenseMapCustomTest, SFINAEMapInfo) {
|
||||
// Test that we can use a pointer to an incomplete type as a DenseMap key.
|
||||
// This is an important build time optimization, since many classes have
|
||||
// DenseMap members.
|
||||
DenseMap<B, int> Map;
|
||||
B Keys[3] = {{0}, {1}, {2}};
|
||||
Map.insert({Keys[0], 1});
|
||||
Map.insert({Keys[1], 2});
|
||||
Map.insert({Keys[2], 3});
|
||||
EXPECT_EQ(Map.count(Keys[0]), 1u);
|
||||
EXPECT_EQ(Map[Keys[0]], 1);
|
||||
EXPECT_EQ(Map[Keys[1]], 2);
|
||||
EXPECT_EQ(Map[Keys[2]], 3);
|
||||
Map.clear();
|
||||
EXPECT_EQ(Map.find(Keys[0]), Map.end());
|
||||
EXPECT_EQ(Map.find(Keys[1]), Map.end());
|
||||
EXPECT_EQ(Map.find(Keys[2]), Map.end());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user