[PATCH] D100668: [ADT] Add STLForwardCompat.h and llvm::disjunction

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 18 11:00:13 PDT 2021


dblaikie accepted this revision.
dblaikie added inline comments.
This revision is now accepted and ready to land.


================
Comment at: llvm/include/llvm/ADT/STLForwardCompat.h:36-37
+template <typename B1, typename... Bn>
+struct conjunction<B1, Bn...>
+    : std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
+
----------------
Hmm, seems this isn't actually conforming implementation (the standard one says that it short-circuits - doesn't try to evaluate later expressions if an early one is true/false - and that the type returned by std::conditional is the type of that last condition that proved the rule, I think?). But probably close enough since it's already committed.


================
Comment at: llvm/unittests/ADT/STLForwardCompatTest.cpp:22-30
+  EXPECT_TRUE((llvm::conjunction<>::value));
+  EXPECT_FALSE((llvm::conjunction<std::false_type>::value));
+  EXPECT_TRUE((llvm::conjunction<std::true_type>::value));
+  EXPECT_FALSE((llvm::conjunction<std::false_type, incomplete_type>::value));
+  EXPECT_FALSE((llvm::conjunction<std::false_type, std::true_type>::value));
+  EXPECT_FALSE((llvm::conjunction<std::true_type, std::false_type>::value));
+  EXPECT_TRUE((llvm::conjunction<std::true_type, std::true_type>::value));
----------------
Was there no existing testing of conjunction? (ie: something that should be deleted as the testing is added/moved here?)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100668/new/

https://reviews.llvm.org/D100668



More information about the llvm-commits mailing list