[llvm] [ADT] Introduce Casting function objects (PR #165803)
Jakub Kuderski via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 3 11:46:07 PST 2025
================
@@ -561,6 +562,53 @@ TEST(CastingTest, assertion_check_unique_ptr) {
<< "Invalid cast of const ref did not cause an abort()";
}
+TEST(Casting, StaticCastPredicate) {
+ std::vector<uint32_t> Values{1, 2};
+
+ EXPECT_TRUE(
+ all_of(map_range(Values, StaticCastTo<uint64_t>),
+ [](const auto &V) { return sizeof(V) == sizeof(uint64_t); }));
+}
+
+TEST(Casting, LLVMRTTIPredicates) {
+ struct Base {
+ enum Kind { BK_Base, BK_Derived };
+ const Kind K;
+ Base(Kind K = BK_Base) : K(K) {}
+ Kind getKind() const { return K; }
+ virtual ~Base() = default;
+ };
+
+ struct Derived : public Base {
----------------
kuhar wrote:
```suggestion
struct Derived : Base {
```
https://github.com/llvm/llvm-project/pull/165803
More information about the llvm-commits
mailing list