[libcxx-commits] [libcxx] [libc++] P2602R2 Poison Pills are Too Toxic (PR #74534)
Jakub Mazurkiewicz via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Dec 6 11:42:09 PST 2023
JMazurkiewicz wrote:
> Could you add some reasoning why this should be DRed?
MSVC and libstdc++ already implemented this paper as a DR. It *mainly* fixes this (rather) unexpected behaviour:
```c++
// https://godbolt.org/z/9h954faET
#include <ranges>
struct Ints {
friend int* begin(const Ints&);
friend int* end(const Ints&);
};
// Good
static_assert(std::ranges::range<const Ints>);
// FAIL! It looks like defect in C++20 ranges design.
static_assert(std::ranges::range<Ints>);
```
>From the paper (end of [§4](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2602r2.html#do-we-still-need-the-poison-pills)):
> [...] the poison pills prevent reasonable code from working and it’s entirely unclear whether they prevent unreasonable code from working.
https://github.com/llvm/llvm-project/pull/74534
More information about the libcxx-commits
mailing list