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// <optional> 11 12// template <class T> struct hash<optional<T>>; 13 14#include <experimental/optional> 15#include <string> 16#include <memory> 17#include <cassert> 18 19 20int main() 21{ 22#if _LIBCPP_STD_VER > 11 23 using std::experimental::optional; 24 25 { 26 typedef int T; 27 optional<T> opt; 28 assert(std::hash<optional<T>>{}(opt) == 0); 29 opt = 2; 30 assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt)); 31 } 32 { 33 typedef std::string T; 34 optional<T> opt; 35 assert(std::hash<optional<T>>{}(opt) == 0); 36 opt = std::string("123"); 37 assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt)); 38 } 39 { 40 typedef std::unique_ptr<int> T; 41 optional<T> opt; 42 assert(std::hash<optional<T>>{}(opt) == 0); 43 opt = std::unique_ptr<int>(new int(3)); 44 assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt)); 45 } 46#endif // _LIBCPP_STD_VER > 11 47} 48