Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我一直在将使用我的自制 span 类的旧代码更新为更符合 C++20 的代码std::span,并且我收到编译错误,因为std::span没有size_type,而是有index_type. index_type关于是否应该签约一直存在巨大的争议,但为什么要跳过size_type呢?这破坏了期望容器(或类似容器的对象)具有size_type.
std::span
size_type
index_type
最初的提案P1022R0在被调用array_view时有一个size_type成员。作为简化的一部分,它在第一个修订版P1022R1中被删除,因为它不需要,因为当时size()元素访问使用有符号index_type(又名ptrdiff_t)。在 Kona 2019 会议上,该决定在P1227R2中更改index_type为size_t.
array_view
size()
ptrdiff_t
size_t
内文所说的一切……都在贝尔法斯特得到了解决。