[libcxx-commits] [PATCH] D121739: [libc++] Add workaround to avoid breaking users of <span> when <ranges> are disabled

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 15 14:13:30 PDT 2022


ldionne created this revision.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Back in 3a208c68942e <https://reviews.llvm.org/rG3a208c68942e9f4d24bd235a6e497852da898cae>, we implemented the range-based constructor for <span>.
However, in doing so, we removed a previous non-standard constructor that
we provided before shipping <ranges>. Unfortunately, that breaks code that
was relying on a range-based constructor until we ship all of <ranges>.

This patch reintroduces the old non-conforming constructors and tests
that were removed in 3a208c68942e <https://reviews.llvm.org/rG3a208c68942e9f4d24bd235a6e497852da898cae> and uses them whenever <ranges> is
not provided (e.g. in LLVM 14). This is only a temporary workaround
until we enable <ranges> by default in C++20, which should hopefully
happen by LLVM 15.

The goal is to cherry-pick this workaround back to the LLVM 14 release
branch, since I suspect the constructor removal may otherwise cause
breakage out there, like the breakage I saw internally.

We could have avoided this situation by waiting for C++20 to be finalized
before shipping std::span. For example, we could have guarded it with
something like _LIBCPP_HAS_NO_INCOMPLETE_RANGES to prevent users from
accidentally starting to depend on it before it is stable. We did not
have these mechanisms when std::span was first implemented, though.

NOTE: This is a pretty modified version of d4c39f1ab94 <https://reviews.llvm.org/rGd4c39f1ab94abc1dd4fff1e82dd4fa97265940e1> since that one
didn't apply properly onto the release/14.x branch.

(cherry picked from commit d4c39f1ab94abc1dd4fff1e82dd4fa97265940e1 <https://reviews.llvm.org/rGd4c39f1ab94abc1dd4fff1e82dd4fa97265940e1>)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121739

Files:
  libcxx/include/span
  libcxx/test/libcxx/containers/views/span.cons/range.pass.cpp
  libcxx/test/libcxx/containers/views/span.cons/range.verify.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121739.415578.patch
Type: text/x-patch
Size: 13455 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220315/b2302ad7/attachment.bin>


More information about the libcxx-commits mailing list