diff options
author | Billy Robert O'Neal III <bion@microsoft.com> | 2017-04-18 00:19:50 +0000 |
---|---|---|
committer | Billy Robert O'Neal III <bion@microsoft.com> | 2017-04-18 00:19:50 +0000 |
commit | e52a34bd9d227934bbfb2cd8e56feeed8cf3e658 (patch) | |
tree | 34a8b73744888452734461d3baadd3ec65ec77b4 /libcxx/test/std/utilities/optional/optional.hash/hash.pass.cpp | |
parent | 1d2ae94b5dbd0ec575b28744a5c34d3a5c133568 (diff) | |
download | bcm5719-llvm-e52a34bd9d227934bbfb2cd8e56feeed8cf3e658.tar.gz bcm5719-llvm-e52a34bd9d227934bbfb2cd8e56feeed8cf3e658.zip |
Allow a standard library to implement conditional noexcept for optional and unique_ptr hash functions.
These tests were unconditionally asserting that optional and unique_ptr declare throwing hashes, but MSVC++ implements conditional noexcept forwarding that of the underlying hash function. As a result we were failing these tests but there's nothing forbidding strengthening noexcept in that way.
Changed the ASSERT_NOT_NOEXCEPT asserts to use types which themselves have non-noexcept hash functions.
llvm-svn: 300516
Diffstat (limited to 'libcxx/test/std/utilities/optional/optional.hash/hash.pass.cpp')
-rw-r--r-- | libcxx/test/std/utilities/optional/optional.hash/hash.pass.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libcxx/test/std/utilities/optional/optional.hash/hash.pass.cpp b/libcxx/test/std/utilities/optional/optional.hash/hash.pass.cpp index 8c91d6da761..b4a1832cdc0 100644 --- a/libcxx/test/std/utilities/optional/optional.hash/hash.pass.cpp +++ b/libcxx/test/std/utilities/optional/optional.hash/hash.pass.cpp @@ -26,7 +26,7 @@ namespace std { template <> struct hash<B> { - size_t operator()(B const&) noexcept(false) { return 0; } + size_t operator()(B const&) TEST_NOEXCEPT_FALSE { return 0; } }; } @@ -37,10 +37,16 @@ int main() const std::size_t nullopt_hash = std::hash<optional<double>>{}(optional<double>{}); + + { + optional<B> opt; + ASSERT_NOT_NOEXCEPT(std::hash<optional<B>>()(opt)); + ASSERT_NOT_NOEXCEPT(std::hash<optional<const B>>()(opt)); + } + { typedef int T; optional<T> opt; - ASSERT_NOT_NOEXCEPT(std::hash<optional<T>>()(opt)); assert(std::hash<optional<T>>{}(opt) == nullopt_hash); opt = 2; assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt)); @@ -48,7 +54,6 @@ int main() { typedef std::string T; optional<T> opt; - ASSERT_NOT_NOEXCEPT(std::hash<optional<T>>()(opt)); assert(std::hash<optional<T>>{}(opt) == nullopt_hash); opt = std::string("123"); assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt)); @@ -56,7 +61,6 @@ int main() { typedef std::unique_ptr<int> T; optional<T> opt; - ASSERT_NOT_NOEXCEPT(std::hash<optional<T>>()(opt)); assert(std::hash<optional<T>>{}(opt) == nullopt_hash); opt = std::unique_ptr<int>(new int(3)); assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt)); |