pointer.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <functional> 11 12// template <class T> 13// struct hash 14// : public unary_function<T, size_t> 15// { 16// size_t operator()(T val) const; 17// }; 18 19// Not very portable 20 21#include <functional> 22#include <cassert> 23#include <type_traits> 24#include <limits> 25 26template <class T> 27void 28test() 29{ 30 static_assert((std::is_base_of<std::unary_function<T, std::size_t>, 31 std::hash<T> >::value), ""); 32 std::hash<T> h; 33 typedef typename std::remove_pointer<T>::type type; 34 type i; 35 type j; 36 assert(h(&i) != h(&j)); 37} 38 39int main() 40{ 41 test<int*>(); 42} 43