[libcxx-commits] [libcxx] [libc++] Implement LWG3133: Modernizing numeric type requirements (PR #208145)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 8 03:09:56 PDT 2026
https://github.com/frederick-vs-ja requested changes to this pull request.
I think we need further changes and test coverage.
----
> - No code changes were needed for `std::valarray<T>`: its `operator[]` already indexes through a raw pointer and never relies on a user-overloadable `operator&`, so it already conforms to the revised wording.
However, I think we should still test this. I think we can use `operator_hijacker` from `operator_hijacker.h` to verify this, and add test cases to
- `libcxx/test/std/numerics/numarray/template.valarray/valarray.access/access.pass.cpp`
- `libcxx/test/std/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp`
----
Moreover, if we do want reject instantiating `valarray` and `complex` with incorrect types, we should `static_assert` all syntactic requirements in "_Cpp17DefaultConstructible_, _Cpp17CopyConstructible_, _Cpp17CopyAssignable_, and _Cpp17Destructible_".
This would be lengthy but implementable. Please be aware of rvalues and non-const lvalues.
Also, we can use `(void)sizeof(std::valarray<T>);` for "pure" instantiation of the class template specialization, which should ensure that we won't reject instantiation too late.
https://github.com/llvm/llvm-project/pull/208145
More information about the libcxx-commits
mailing list