[libcxx-commits] [PATCH] D109475: [libc++] Simplify span specializations

Joe Loser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 8 17:36:29 PDT 2021


jloser created this revision.
jloser added reviewers: ldionne, Quuxplusone, Mordante, zoecarver, cjdb.
jloser requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

`span` has a partial class template specialization for when the extent
is dynamic. This leads to a lot of repeated code (for type aliases,
constraints on constructors, etc.) which is not ideal. It makes for more
of a maintenance burden as more things are added to `span` such as
current work I'm doing with P1394 <https://reviews.llvm.org/P1394>.

Refactor `span` to be just one class template and handle the few differences
between static and dynamic extents with appropriate constraints and
`if constexpr` where needed. Only store the extent data member when the extent
is dynamic. This ensures no additional storage overhead when the span has a
static extent.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109475

Files:
  libcxx/include/span
  libcxx/test/std/containers/views/span.cons/span.pass.cpp
  libcxx/test/std/containers/views/span.sub/subspan.fail.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109475.371480.patch
Type: text/x-patch
Size: 20113 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210909/8723bb3d/attachment-0001.bin>


More information about the libcxx-commits mailing list