-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc++][span] P2447R4: std::span
over an initializer list
#78157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Zingam
merged 12 commits into
llvm:main
from
H-G-Hristov:hgh/libcxx/P2447R4-span-over-initializer_list
Jan 20, 2024
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
01f0ed0
[libc++][span] P2447R4: `std::span` over an initializer list
Zingam 780d857
WIP: Cleanup
Zingam cbe6fa0
Added generated version files
Zingam de98ad0
Added SFINAE
Zingam 7add5b4
Cleanup
Zingam 801cb18
Try to fix CI
Zingam 2383ac3
Try to fix CI
Zingam 6c89879
WIP: Addressed some comments
Zingam 2172198
Addressed comments
Zingam bf4c7bd
Merge branch 'main' into hgh/libcxx/P2447R4-span-over-initializer_list
H-G-Hristov 7296803
Merge branch 'main' into hgh/libcxx/P2447R4-span-over-initializer_list
H-G-Hristov 205d982
Addressed comment
Zingam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
libcxx/test/std/containers/views/views.span/span.cons/initializer_list.assert.pass.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23 | ||
|
||
// REQUIRES: has-unix-headers | ||
// REQUIRES: libcpp-hardening-mode={{extensive|debug}} | ||
// XFAIL: availability-verbose_abort-missing | ||
|
||
// <span> | ||
|
||
// constexpr explicit(extent != dynamic_extent) span(std::initializer_list<value_type> il); // Since C++26 | ||
|
||
#include <cassert> | ||
#include <initializer_list> | ||
#include <span> | ||
|
||
#include "check_assertion.h" | ||
|
||
int main(int, char**) { | ||
TEST_LIBCPP_ASSERT_FAILURE( | ||
(std::span<const int, 4>({1, 2, 3, 9084, 5})), "Size mismatch in span's constructor _Extent != __il.size()."); | ||
TEST_LIBCPP_ASSERT_FAILURE((std::span<const int, 4>(std::initializer_list<int>{1, 2, 3, 9084, 5})), | ||
"Size mismatch in span's constructor _Extent != __il.size()."); | ||
|
||
return 0; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
libcxx/test/std/containers/views/views.span/span.cons/initializer_list.verify.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// UNSUPPORTED: c++03, c++11, c++14, c++17 | ||
|
||
// <span> | ||
|
||
// constexpr explicit(extent != dynamic_extent) span(std::initializer_list<value_type> il); // Since C++26 | ||
|
||
#include <span> | ||
#include <utility> | ||
|
||
#include "test_macros.h" | ||
|
||
// Test P2447R4 "Annex C examples" | ||
|
||
void one(std::pair<int, int>); | ||
void one(std::span<const int>); | ||
|
||
void two(std::span<const int, 2>); | ||
|
||
void test_P2447R4_annex_c_examples() { | ||
// 1. Overload resolution is affected | ||
#if TEST_STD_VER >= 26 | ||
// expected-error@+1 {{call to 'one' is ambiguous}} | ||
one({1, 2}); | ||
#else | ||
// expected-no-diagnostics | ||
one({1, 2}); | ||
#endif | ||
|
||
// 2. The `initializer_list` ctor has high precedence | ||
#if TEST_STD_VER >= 26 | ||
// expected-error@+1 {{chosen constructor is explicit in copy-initialization}} | ||
two({{1, 2}}); | ||
#else | ||
// expected-no-diagnostics | ||
two({{1, 2}}); | ||
#endif | ||
|
||
// 3. Implicit two-argument construction with a highly convertible value_type | ||
// --> tested in "initializer_list.pass.cpp" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! thanks for referring to the other test too!