[libcxx-commits] [PATCH] D96742: [libcxx] adds concept `std::assignable_from`

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Feb 19 14:11:09 PST 2021


ldionne added a comment.

The implementation matches the spec closely. I didn't look at the tests in careful detail, however as a general high-level comment: is there value in testing these concepts on a few common types like `std::string`, `std::vector`, etc. just to make sure they behave as we'd expect them?

Those are the first types that users are going to use concepts with, so I tend to see value in making sure they work as expected (not that I see any reason they wouldn't, but catching bad surprises is the whole point). Basically, it's as if we had a few compilable examples of how to use the Standard Library.



================
Comment at: libcxx/test/std/concepts/lang/assignable.compile.pass.cpp:21
+constexpr bool ModelsAssignableFrom() {
+  static_assert(!std::assignable_from<T1, T2>);
+  static_assert(!std::assignable_from<T1, const T2>);
----------------
Should we use the trick that Casey mentioned in another patch where we basically test `static_assert(std::assignable_from<T1, const T2> == std::assignable_from<T1, T2>);`?

That way, you could use something like this below: `static_assert(!ModelsAssignableFrom<int*&, const int*>());`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96742



More information about the libcxx-commits mailing list