Home | History | Annotate | Download | only in unord.hash
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // UNSUPPORTED: c++98, c++03, c++11
     11 
     12 // <functional>
     13 
     14 //  Hashing a struct w/o a defined hash should *not* fail, but it should
     15 // create a type that is not constructible and not callable.
     16 // See also: http://cplusplus.github.io/LWG/lwg-active.html#2543
     17 
     18 #include <functional>
     19 #include <cassert>
     20 #include <type_traits>
     21 
     22 #include "test_macros.h"
     23 
     24 struct X {};
     25 
     26 int main()
     27 {
     28     using H = std::hash<X>;
     29     static_assert(!std::is_default_constructible<H>::value, "");
     30     static_assert(!std::is_copy_constructible<H>::value, "");
     31     static_assert(!std::is_move_constructible<H>::value, "");
     32     static_assert(!std::is_copy_assignable<H>::value, "");
     33     static_assert(!std::is_move_assignable<H>::value, "");
     34 #if TEST_STD_VER > 14
     35     static_assert(!std::is_callable<H(X&)>::value, "");
     36     static_assert(!std::is_callable<H(X const&)>::value, "");
     37 #endif
     38 }
     39