| //===----------------------------------------------------------------------===// |
| // 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, c++14 |
| // template <class T> struct hash<optional<T>>; |
| const std::size_t nullopt_hash = |
| std::hash<optional<double>>{}(optional<double>{}); |
| assert(std::hash<optional<T>>{}(opt) == nullopt_hash); |
| assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt)); |
| assert(std::hash<optional<T>>{}(opt) == nullopt_hash); |
| opt = std::string("123"); |
| assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt)); |
| typedef std::unique_ptr<int> T; |
| assert(std::hash<optional<T>>{}(opt) == nullopt_hash); |
| opt = std::unique_ptr<int>(new int(3)); |
| assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt)); |