Implement the header <span> for C++20.
This is a very large patch, but almost 90% of the code is tests. (4400 lines of 5000)
The paper can be found here https://wg21.link/P0122
Paths
| Differential D49338
Implement <span> - P0122R7 ClosedPublic Authored by mclow.lists on Jul 13 2018, 10:47 PM.
Details Summary Implement the header <span> for C++20. This is a very large patch, but almost 90% of the code is tests. (4400 lines of 5000)
Diff Detail Event Timeline
mclow.lists marked an inline comment as done. Comment Actions My comments are based off of http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0122r7.pdf.
This revision now requires changes to proceed.Jul 23 2018, 12:55 PM Comment Actions I think I've answered all of Louis' questions that don't require code changes.
Comment Actions I missed the container constructors being noexcept, and the asserts on operator[] and operator() are half done (stupid signed indicies). I'll wait for other feedback before doing those bits.
Comment Actions
Never mind; they're not noexcept (and they should not be)
Comment Actions Fix the assertions in the indexing operators. Also change a bunch of the tests to use ASSERT_SAME_TYPE and ASSERT_NOEXCEPT. No functional change there, just better names. Comment Actions LGTM, with a suggestion for adding one test.
This revision is now accepted and ready to land.Jul 23 2018, 4:42 PM
Revision Contents
Diff 156879 include/CMakeLists.txt
include/module.modulemap
include/span
test/libcxx/double_include.sh.cpp
test/std/containers/views/span.comparison/op.eq.pass.cpptest/std/containers/views/span.comparison/op.ge.pass.cpp
test/std/containers/views/span.comparison/op.gt.pass.cpp
test/std/containers/views/span.comparison/op.le.pass.cpp
test/std/containers/views/span.comparison/op.lt.pass.cpp
test/std/containers/views/span.comparison/op.ne.pass.cpp
test/std/containers/views/span.cons/array.fail.cpp
test/std/containers/views/span.cons/array.pass.cpp
test/std/containers/views/span.cons/assign.pass.cpp
test/std/containers/views/span.cons/container.fail.cpptest/std/containers/views/span.cons/container.pass.cpp
test/std/containers/views/span.cons/copy.pass.cpp
test/std/containers/views/span.cons/deduct.pass.cpptest/std/containers/views/span.cons/default.fail.cpp
test/std/containers/views/span.cons/default.pass.cpptest/std/containers/views/span.cons/ptr_len.fail.cpp
test/std/containers/views/span.cons/ptr_len.pass.cpp
test/std/containers/views/span.cons/ptr_ptr.fail.cpp
test/std/containers/views/span.cons/ptr_ptr.pass.cpp
test/std/containers/views/span.cons/span.fail.cpp
test/std/containers/views/span.cons/span.pass.cpptest/std/containers/views/span.cons/stdarray.pass.cpp
test/std/containers/views/span.elem/data.pass.cpp
test/std/containers/views/span.elem/op_idx.pass.cpp
test/std/containers/views/span.iterators/begin.pass.cpptest/std/containers/views/span.iterators/end.pass.cpp
test/std/containers/views/span.iterators/rbegin.pass.cpptest/std/containers/views/span.iterators/rend.pass.cpp
test/std/containers/views/span.objectrep/as_bytes.pass.cpptest/std/containers/views/span.objectrep/as_writeable_bytes.fail.cpp
test/std/containers/views/span.objectrep/as_writeable_bytes.pass.cpptest/std/containers/views/span.obs/empty.pass.cpp
test/std/containers/views/span.obs/size.pass.cpp
test/std/containers/views/span.obs/size_bytes.pass.cpp
test/std/containers/views/span.sub/first.pass.cpp
test/std/containers/views/span.sub/last.pass.cpptest/std/containers/views/span.sub/subspan.pass.cpptest/std/containers/views/types.pass.cpp |
You seem to be missing the following condition from the paper: is_array_v<Container> is false. Are you omitting it because the array overloads would take precedence over this constructor if an array were passed? If so, I think there's a bug since you could be passing an array of incorrect size and this constructor would kick in. The overload for ElementType(*)[N] would be discarded because of a mismatched N, but this one wouldn't (I think).
If I'm right, this would turn what should be a compilation failure into a runtime error with the _LIBCPP_ASSERT(_Extent == _VSTD::size(__c)).