-
Notifications
You must be signed in to change notification settings - Fork 16.2k
[libc++] Remove the constexpr hash<vector<bool>> extension
#132617
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
frederick-vs-ja
merged 14 commits into
llvm:main
from
frederick-vs-ja:libcxx-test-constexpr-hash-vector-bool
May 13, 2025
Merged
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7db09d6
[libc++][test ] Make tests for constexpr `hash` libcxx-specific
frederick-vs-ja 38d2fe3
Templatize tests, remove unused inclusion
frederick-vs-ja de029f8
Add transient missing include
frederick-vs-ja 7d9123a
Remove extension
frederick-vs-ja 465ddfd
Remov escape hatch
frederick-vs-ja abc0689
Templatize existing tests
frederick-vs-ja 2e5416d
Make templaitization less awkward
frederick-vs-ja b9772ff
Merge branch 'main' into libcxx-test-constexpr-hash-vector-bool
frederick-vs-ja 7f06fa2
Merge branch 'main' into libcxx-test-constexpr-hash-vector-bool
frederick-vs-ja 6a93adf
Up with `typename`
frederick-vs-ja e00077b
Merge branch 'main' into libcxx-test-constexpr-hash-vector-bool
frederick-vs-ja 3e056a5
Merge branch 'main' into libcxx-test-constexpr-hash-vector-bool
frederick-vs-ja 8adad37
Merge branch 'main' into libcxx-test-constexpr-hash-vector-bool
frederick-vs-ja 0b0014f
Merge branch 'main' into libcxx-test-constexpr-hash-vector-bool
ldionne 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
49 changes: 49 additions & 0 deletions
49
libcxx/test/libcxx/containers/sequences/vector.bool/hash.constexpr.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,49 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // REQUIRES: std-at-least-c++20 | ||
|
|
||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_REMOVED_CONSTEXPR_HASH_VECTOR_BOOL | ||
|
|
||
| // <vector> | ||
|
|
||
| // template<class Allocator> struct hash<vector<bool, Allocator>>; | ||
|
|
||
| // Since LLVM 16, libc++ has made the operator() of this partial specialization constexpr since C++20, | ||
| // which is a conforming extension. However, such extension was unintended, and is being removed. | ||
|
|
||
| #include <cassert> | ||
| #include <functional> | ||
| #include <vector> | ||
|
|
||
| #include "min_allocator.h" | ||
|
|
||
| template <class VBType> | ||
| constexpr void test() { | ||
| bool ba[]{true, false, true, true, false}; | ||
| VBType vb(std::begin(ba), std::end(ba)); | ||
|
|
||
| const std::hash<VBType> h{}; | ||
| const auto hash_value = h(vb); | ||
| assert(hash_value == h(vb)); | ||
| assert(hash_value != 0); | ||
| } | ||
|
|
||
| constexpr bool test() { | ||
| test<std::vector<bool>>(); | ||
| test<std::vector<bool, min_allocator<bool>>>(); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| int main(int, char**) { | ||
| test(); | ||
| static_assert(test()); | ||
|
|
||
| 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
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
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.
Uh oh!
There was an error while loading. Please reload this page.