HomePhabricator

span: update constructors to match c++20 draft spec and add lifetimebound…

Description

span: update constructors to match c++20 draft spec and add lifetimebound attribute

Summary:

span: (almost) match std::span's constructor behavior

c++20's draft of std::span no longer includes move constructors.

span: add lifetimebound attribute

See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0936r0.pdf for
reference.

This helps to guard against dangling references caused by construction from
temporaries such as:

`Span<const int> sp(std::vector<int>{1,2,3});`

Add lifetimebound to attributes for general-purpose usage

Co-authored-by: practicalswift <practicalswift@users.noreply.github.com>

This is a backport of core#19387

Test Plan:
With clang and gcc:
ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10888

Details

Provenance
Cory Fields <cory-nospam-@coryfields.com>Authored on Jun 26 2020, 17:21
PiRKCommitted on Jan 26 2022, 08:19
PiRKPushed on Jan 26 2022, 08:19
Reviewer
Restricted Project
Differential Revision
D10888: span: update constructors to match c++20 draft spec and add lifetimebound attribute
Parents
rABC05a5cdd2ba6b: Rename ping members
Branches
Unknown
Tags
Unknown