Files
libcxx/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp
Eric Fiselier 2d08bc9a9f 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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@278300 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-10 22:45:26 +00:00

39 lines
1.2 KiB
C++

//===----------------------------------------------------------------------===//
//
// 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
}