[libcxx-commits] [PATCH] D143447: [libc++] Implement P1328R1 constexpr std::type_info::operator==

Aaron Ballman via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 7 08:34:41 PST 2023


aaron.ballman added inline comments.


================
Comment at: libcxx/test/std/language.support/support.rtti/type.info/type_info.equal.pass.cpp:31-34
+static constexpr Derived D;
+constexpr const Base &get_it() {
+  return D;
+}
----------------
These are unused in the test.


================
Comment at: libcxx/test/std/language.support/support.rtti/type.info/type_info.equal.pass.cpp:41
+    std::type_info const& t2 = typeid(long);
+    assert(t1 == t1);
+    assert(t2 == t2);
----------------
I'm very unfamiliar with libc++ testing patterns, but does something ensure that the `assert` macro actually expands to test things even in `NDEBUG` builds?


================
Comment at: libcxx/test/std/language.support/support.rtti/type.info/type_info.equal.pass.cpp:11
+//
+//  bool operator==(const type_info& rhs) const noexcept; // constexpr since C++23
+
----------------
ldionne wrote:
> aaron.ballman wrote:
> > Mordante wrote:
> > > Can you add a test for `noexcept` too?
> > I'd also like a test for typeid of a polymorphic type since that's special. e.g.,
> > ```
> > #include <typeinfo>
> > 
> > struct Base {
> >   virtual void func() {}
> > };
> > struct Derived : Base {
> >   virtual void func() {}
> > };
> > 
> > static constexpr Derived D;
> > constexpr const Base &get_it() {
> >   return D;
> > }
> > 
> > static_assert(typeid(get_it()) == typeid(Derived));
> > ```
> > (or something similar)
> Addressed both. Aaron, it'd be great if you could have a look to make sure the test I added addresses what you wanted -- I think it does.
I think it does as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143447



More information about the libcxx-commits mailing list