test_hash.h 843 B

12345678910111213141516171819202122232425262728293031
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef TEST_HASH_H
  9. #define TEST_HASH_H
  10. #include <cstddef>
  11. #include <type_traits>
  12. template <class C>
  13. class test_hash
  14. : private C
  15. {
  16. int data_;
  17. public:
  18. explicit test_hash(int data = 0) : data_(data) {}
  19. std::size_t
  20. operator()(typename std::add_lvalue_reference<const typename C::argument_type>::type x) const
  21. {return C::operator()(x);}
  22. bool operator==(const test_hash& c) const
  23. {return data_ == c.data_;}
  24. };
  25. #endif // TEST_HASH_H