[libc++] Work around a Clang bug in transform_view, and regression-test.
authorArthur O'Dwyer <arthur.j.odwyer@gmail.com>
Sun, 5 Dec 2021 15:08:05 +0000 (10:08 -0500)
committerArthur O'Dwyer <arthur.j.odwyer@gmail.com>
Mon, 6 Dec 2021 16:20:08 +0000 (11:20 -0500)
commitdcdb07abce278a65e1a8df164ce9b942da6ebd23
tree26c020f97104fcb5b0be61f7d26ba343d2b32c78
parentf6ba6450396ce58212f247c72d84a54efd748b38
[libc++] Work around a Clang bug in transform_view, and regression-test.

Clang trunk rejects the new test case, but this is a Clang bug
(PR47414, 47509, 50864, 44833).

```
In module 'std' imported from /Users/aodwyer/llvm-project/libcxx/test/std/ranges/range.adaptors/range.transform/general.pass.cpp:17:
/Users/aodwyer/llvm-project/build2/include/c++/v1/__ranges/transform_view.h:85:44: error: constraints not satisfied for alias template 'range_reference_t' [with _Rp = const NonConstView]
             regular_invocable<const _Fn&, range_reference_t<const _View>>
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/aodwyer/llvm-project/build2/include/c++/v1/__ranges/transform_view.h:416:25: note: in instantiation of template class 'std::ranges::transform_view<NonConstView, (lambda at /Users/aodwyer/llvm-project/libcxx/test/std/ranges/range.adaptors/range.transform/general.pass.cpp:73:71)>' requested here
      -> decltype(      transform_view(_VSTD::forward<_Range>(__range), _VSTD::forward<_Fn>(__f)))
                        ^
```

We can work around this by adding a layer of indirection: put the
problematic constraint into a named concept and Clang becomes more
amenable to SFINAE'ing instead of hard-erroring.

Drive-by simplify `range.transform/general.pass.cpp` to make it clearer
what it's actually testing in this area.

Differential Revision: https://reviews.llvm.org/D115116
libcxx/include/__ranges/transform_view.h
libcxx/test/std/ranges/range.adaptors/range.transform/general.pass.cpp