boost::span cannot be implicitly constructed from `std::initializer_list` indirectly [feature-request]
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- Half a day
- Newbie friendliness
- 35/100
Research direction
No source file or test is named. Start by locating boost::span's constructor overloads and the existing span test coverage, then check the issue's direct-list-initialization example. Done means the example compiles and equivalent coverage confirms the intended initializer-list behavior without regressing existing range construction.
Written by the indexing model from the issue text.
Description
NOTE: This isn't something std::span in C++20 supports either, unfortunately. But since Boost tries to offer things a future standard might adopt, I think this fits?
Because boost::span has no constructor signature with a direct std::initializer_list argument, but only a templated "range" one, this works:
std::initializer_list<int> il{1,2,3,4};
boost::span<int> sp(il);
but this does not, because it requires two implicit conversions to occur:
boost::span<int> sp({1,2,3,4});
I believe the above would work if this were to be added:
constexpr span(std::initializer_list<T> il) noexcept
: s_(boost::data(il), il.size())
{}
I can provide a PR, if you wish.
I recognize this can lead to lifetime issues for the backing array, but that's already true for span regardless.
There is a std proposal for this, I believe: p2447r2, but I don't know its disposition.
- Dominant language
- C++
- Stars
- 156
- Forks
- 116
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/core
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
-
Difficulty 1/5 Under an hour Newbie friendliness 55/100
-
saturate_castOpen
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
move span to boost::core::May be free again @glenfe claimed this 493 days ago, and no pull request is open. Open
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
shadps4-emu/shadps4-qtlauncher#453 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
google/differential-privacy#516 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
plengauer/DXGIOutputDuplication#76 ·
Maintainers usually reply within 1 day
-
Feature
Difficulty 1/5 Under an hour Newbie friendliness 65/100
Narezzurri/OpenVPN-Config-Manager#95 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rhalbersma/xstd-bits#314 ·
Maintainers usually reply within 1 day