diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-08-10 22:45:26 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-08-10 22:45:26 +0000 |
commit | 45b7b44867f75098c4235bda09fa088d0cb803f3 (patch) | |
tree | 206bf3d88372f96d14a10f5f28749896e745a49c /libcxx/test/std/utilities/function.objects/unord.hash | |
parent | ee1f578d627cddc71c691ba53f469ed114159454 (diff) | |
download | bcm5719-llvm-45b7b44867f75098c4235bda09fa088d0cb803f3.tar.gz bcm5719-llvm-45b7b44867f75098c4235bda09fa088d0cb803f3.zip |
Implement LWG 2148: Make non-enum default hash specialization well-formed
Summary:
This patch removes the static_assert for non-enum types in the primary hash template. Instead non-enum types create a hash<T> specialization that is not constructible nor callable.
See also:
* http://cplusplus.github.io/LWG/lwg-active.html#2543
* https://llvm.org/bugs/show_bug.cgi?id=28917
Reviewers: mclow.lists, EricWF
Subscribers: mehdi_amini, cfe-commits
Differential Revision: https://reviews.llvm.org/D23331
llvm-svn: 278300
Diffstat (limited to 'libcxx/test/std/utilities/function.objects/unord.hash')
-rw-r--r-- | libcxx/test/std/utilities/function.objects/unord.hash/enum.pass.cpp | 7 | ||||
-rw-r--r-- | libcxx/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp | 38 |
2 files changed, 40 insertions, 5 deletions
diff --git a/libcxx/test/std/utilities/function.objects/unord.hash/enum.pass.cpp b/libcxx/test/std/utilities/function.objects/unord.hash/enum.pass.cpp index 8aa2c1df893..af367789a10 100644 --- a/libcxx/test/std/utilities/function.objects/unord.hash/enum.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/unord.hash/enum.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11 + // <functional> // make sure that we can hash enumeration values @@ -14,8 +16,6 @@ #include "test_macros.h" -#if TEST_STD_VER >= 14 - #include <functional> #include <cassert> #include <type_traits> @@ -59,6 +59,3 @@ int main() test<Fruits>(); } -#else -int main () {} -#endif diff --git a/libcxx/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp b/libcxx/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp new file mode 100644 index 00000000000..ed173f280d0 --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <functional> + +// Hashing a struct w/o a defined hash should *not* fail, but it should +// create a type that is not constructible and not callable. +// See also: http://cplusplus.github.io/LWG/lwg-active.html#2543 + +#include <functional> +#include <cassert> +#include <type_traits> + +#include "test_macros.h" + +struct X {}; + +int main() +{ + using H = std::hash<X>; + static_assert(!std::is_default_constructible<H>::value, ""); + static_assert(!std::is_copy_constructible<H>::value, ""); + static_assert(!std::is_move_constructible<H>::value, ""); + static_assert(!std::is_copy_assignable<H>::value, ""); + static_assert(!std::is_move_assignable<H>::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_callable<H(X&)>::value, ""); + static_assert(!std::is_callable<H(X const&)>::value, ""); +#endif +} |