Page MenuHomePhabricator

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

Authored by PiRK on Jan 25 2022, 14:12.

Details

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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Jan 25 2022, 14:12
Fabien requested changes to this revision.Jan 25 2022, 14:37
Fabien added a subscriber: Fabien.

The test plan does not cover the change

This revision now requires changes to proceed.Jan 25 2022, 14:37
PiRK requested review of this revision.Jan 25 2022, 15:42
PiRK edited the test plan for this revision. (Show Details)

updated test plan to test both gcc and clang

This revision is now accepted and ready to land.Jan 26 2022, 08:15